Bug 81980 Unexpected unresolved enum quick fix suggestions [quick fix] [5.0]
Although the create field and create constant in my enum type suggestions for the quick fix in the code listed below compiles and works fine. It is not quite what I expected for the use of enumerated types. public class EnumQuickFixBug implements Runnable { private State state; private enum State {begin, end}; public void run() { state = State.begin; // Try quick fixing the line below state = State.middle; state = State.end; } public static void main(String args[]) { EnumQuickFixBug bugs = new EnumQuickFixBug(); bugs.run(); System.out.println("Done"); } } I expected to declaration of the enum type to change to something like: private enum State {begin, end, middle}; but instead it did something like this: private enum State {begin, end; public static State middle;};
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/UnresolvedElementsSubProcessor.java
private static boolean isLikelyTypeParameterName(String name) {
		return name.length() == 1 && Character.isUpperCase(name.charAt(0));
	}
	private static void addNewTypeProposals(ICompilationUnit cu, Name refNode, int kind, int relevance, Collection proposals) throws JavaModelException {
		Name node= refNode;
		do {
			String typeName= ASTNodes.getSimpleNameIdentifier(node);
			Name qualifier= null;
			
			boolean isPossibleName= isLikelyTypeName(typeName) || (node == refNode);
			if (isPossibleName) {
				IPackageFragment enclosingPackage= null;
				IType enclosingType= null;
				if (node.isSimpleName()) {
					enclosingPackage= (IPackageFragment) cu.getParent();
					
				} else {
					Name qualifierName= ((QualifiedName) node).getQualifier();
					 IBinding binding= qualifierName.resolveBinding(); 
					 if (binding instanceof ITypeBinding) {
						enclosingType=(IType) binding.getJavaElement();
					 } else if (binding instanceof IPackageBinding) {
						qualifier= qualifierName;
					 	enclosingPackage= (IPackageFragment) binding.getJavaElement();
					 } else {
					 	IJavaElement[] res= cu.codeSelect(qualifierName.getStartPosition(), qualifierName.getLength());
						if (res!= null && res.length > 0 && res[0] instanceof IType) {
							enclosingType= (IType) res[0];
						} else {