Bug 73890 [1.5] Convert to enhanced for loop quick assist should not be available if counter is used in loop
I20040907 Have the following: for (int i= 0, length= numbers.length; i < length; i++) { int number= numbers[i]; System.out.println("Number " + i + ": " + new Integer(numbers[i])); } The quick assist allows me to convert this into code which causes a compile error: for (int element : numbers) { System.out.println("Number " + i + ": " + new Integer(numbers[i])); } Note: if I first assign int number= numbers[i]; and use number instead of numbers[i] in the println then the quick assist is not offered (correct).
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/ConvertForLoopProposal.java
fOldCollectionTypeBinding= qualifier.resolveTypeBinding();
			} else if (rightOperand.getNodeType() == ASTNode.METHOD_INVOCATION) {
				MethodInvocation methodCall= (MethodInvocation)rightOperand;
				Expression exp= methodCall.getExpression();
				if (exp instanceof Name) {
					Name collectionName= (Name)exp;
					fOldCollectionBinding= collectionName.resolveBinding();
					fOldCollectionTypeBinding= collectionName.resolveTypeBinding();
					fCollectionName= ASTNodeFactory.newName(fAst,collectionName.getFullyQualifiedName());
				}
			} else if (rightOperand instanceof FieldAccess){
				 
				 
				FieldAccess fieldAccess= (FieldAccess) rightOperand;
				if ("length".equals(fieldAccess.getName().getIdentifier())) { 
					fCollectionIsMethodCall= true;
					if (fieldAccess.getExpression() instanceof MethodInvocation){
						MethodInvocation methodCall= (MethodInvocation) fieldAccess.getExpression();
						fMethodInvocation= methodCall;
						fOldCollectionBinding= methodCall.resolveMethodBinding();
						fOldCollectionTypeBinding= methodCall.resolveTypeBinding();
						fCollectionName= ASTNodeFactory.newName(fAst, methodCall.getName().getFullyQualifiedName());
					}
				}
				
			}
		}
	}
	private void doInferCollectionFromInitializers() {
		List initializers= fOldForStatement.initializers();