Bug 39473 [quick fix] "Create method" quickfix offers to create duplicate method in enclosing type
200306250800 1. have a class, e.g. public class MyAction implements IEditorActionDelegate { public void run(IAction action) {} void myMethod() { Runnable r= new Runnable() { public void run() { Action a; <HERE> run(a); } } } } 2. correctly, an error is displayed at <LINE> 3. Quickfix offers to create a local method matching the parameter, which is fine, but also: - Change method run(IAction) to run(IAction) which is idempotent - Create method run(IAction) in MyAction The latter inserts a method run(Action) in the enclosing type which will be marked as a duplicate. -> Enhancement and fix request: add quickfix "change to call to enclosing type" should produce the following code at <LINE> MyAction.this.run(a);
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/UnresolvedElementsSubProcessor.java
if (nDiffs == 1) { 
			int idx= indexOfDiff[0];
			Expression nodeToCast= (Expression) arguments.get(idx);
			String castType= paramTypes[idx].getQualifiedName();			
			ASTRewriteCorrectionProposal proposal= LocalCorrectionsSubProcessor.getCastProposal(context, castType, nodeToCast, 6);
			if (proposal != null) { 
				proposals.add(proposal);
				String[] arg= new String[] { String.valueOf(idx + 1), castType };
				proposal.setDisplayName(CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.addargumentcast.description", arg)); 
			}
		}
		if (nDiffs == 2) { 
			int idx1= indexOfDiff[0];
			int idx2= indexOfDiff[1];
			boolean canSwap= TypeRules.canAssign(argTypes[idx1], paramTypes[idx2]) && TypeRules.canAssign(argTypes[idx2], paramTypes[idx1]);
			 if (canSwap) {
				Expression arg1= (Expression) arguments.get(idx1);
				Expression arg2= (Expression) arguments.get(idx2);
				
				ASTRewrite rewrite= new ASTRewrite(arg1.getParent());
				rewrite.markAsReplaced(arg1, rewrite.createCopy(arg2));
				rewrite.markAsReplaced(arg2, rewrite.createCopy(arg1));
				{
					String[] arg= new String[] { String.valueOf(idx1 + 1), String.valueOf(idx2 + 1) };
					String label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.swaparguments.description", arg); 
					Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
					ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, context.getCompilationUnit(), rewrite, 8, image);
					proposal.ensureNoModifications();
					proposals.add(proposal);					
				}