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
if (nDiffs == 1) { 
			int idx= indexOfDiff[0];
			Expression nodeToCast= (Expression) arguments.get(idx);
			ITypeBinding castType= paramTypes[idx];
			ITypeBinding binding= nodeToCast.resolveTypeBinding();
			if (binding == null || TypeRules.canCast(castType, binding)) {
				String castTypeName= castType.getQualifiedName();
				ASTRewriteCorrectionProposal proposal= TypeMismatchSubProcessor.createCastProposal(context, castTypeName, castType, nodeToCast, 6);
				String[] arg= new String[] { getArgumentName(cu, arguments, idx), castTypeName};
				proposal.setDisplayName(CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.addargumentcast.description", arg)); 
				proposals.add(proposal);
			}
			TypeMismatchSubProcessor.addChangeSenderTypeProposals(context, nodeToCast, castType, false, 5, proposals);
		}
		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= ASTRewrite.create(astRoot.getAST());
				rewrite.replace(arg1, rewrite.createCopyTarget(arg2), null);
				rewrite.replace(arg2, rewrite.createCopyTarget(arg1), null);
				{
					String[] arg= new String[] { getArgumentName(cu, arguments, idx1), getArgumentName(cu, arguments, idx2) };
					String label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.swaparguments.description", arg); 
					Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);