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
binding= binding.getElementType();
			}
			resolvedTypeName= binding.getQualifiedName();
			proposals.add(createTypeRefChangeProposal(cu, resolvedTypeName, node, relevance + 2));
		}
		
		for (int i= 0; i < elements.length; i++) {
			SimilarElement elem= elements[i];
			if ((elem.getKind() & SimilarElementsRequestor.ALL_TYPES) != 0) {
				String fullName= elem.getName();
				if (!fullName.equals(resolvedTypeName)) {
					proposals.add(createTypeRefChangeProposal(cu, fullName, node, relevance));
				}
			}
		}
	}
	private static CUCorrectionProposal createTypeRefChangeProposal(ICompilationUnit cu, String fullName, Name node, int relevance) throws JavaModelException {
		CUCorrectionProposal proposal= new CUCorrectionProposal("", cu, 0); 
		ImportEdit importEdit= new ImportEdit(cu, JavaPreferencesSettings.getCodeGenerationSettings());				
		String simpleName= importEdit.addImport(fullName);
		
		TextEdit root= proposal.getRootTextEdit();
		
		if (!importEdit.isEmpty()) {
			root.add(importEdit); 
		}
		String[] arg= { simpleName, Signature.getQualifier(fullName) };
		if (node.isSimpleName() && simpleName.equals(((SimpleName) node).getIdentifier())) { 
			proposal.setImage(JavaPluginImages.get(JavaPluginImages.IMG_OBJS_IMPDECL));
			proposal.setDisplayName(CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.importtype.description", arg));