Bug 80364 [Quick Assist] "Assign parameter to field" does not work for existing field
In this small example, there does not occur the quick-fix to "Assign parameter to new field": public class Foo { private final Bar bar; public Foo(Bar bar) { } } Even worse: when I remove the final from the variable declaration, invoking the quick-fix creates a new variable bar2 instead of reusing the existing one.
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/AssignToVariableAssistProposal.java
return getImportRewrite().addImport(fTypeBinding, ast);
	}
	private String[] suggestLocalVariableNames(ITypeBinding binding, Expression expression) {
		ArrayList res= new ArrayList();
		IJavaProject project= getCompilationUnit().getJavaProject();
		ITypeBinding base= binding.isArray() ? binding.getElementType() : binding;
		IPackageBinding packBinding= base.getPackage();
		String packName= packBinding != null ? packBinding.getName() : ""; 
		String[] excludedNames= getUsedVariableNames();
		String name= ASTResolving.getBaseNameFromExpression(project, expression);
		if (name != null) {
			String[] argname= StubUtility.getLocalNameSuggestions(project, name, 0, excludedNames); 
			for (int i= 0; i < argname.length; i++) {
				String curr= argname[i];
				if (!res.contains(curr)) {
					res.add(curr);
				}
			}
		}
		String typeName= base.getName();
		String[] names= NamingConventions.suggestLocalVariableNames(project, packName, typeName, binding.getDimensions(), excludedNames);
		for (int i= 0; i < names.length; i++) {
			String curr= names[i];
			if (!res.contains(curr)) {
				res.add(curr);
			}
		}
		return (String[]) res.toArray(new String[res.size()]);
	}
	private String[] suggestFieldNames(ITypeBinding binding, Expression expression, int modifiers) {