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
fEnhancedForStatement.setExpression(createExpression(rewrite));
		fEnhancedForStatement.setParameter(fParameterDeclaration);
		addLinkedPosition(rewrite.track(fParameterDeclaration.getName()), true, ConvertForLoopProposal.ELEMENT_KEY_REFERENCE);
		addProposalsForElement();
		rewrite.replace(fOldForStatement, fEnhancedForStatement, null);
	}
	
	private Expression createExpression(ASTRewrite rewrite) {
		if (fCollectionIsMethodCall){
			MethodInvocation methodCall= (MethodInvocation) rewrite.createMoveTarget(fMethodInvocation);
			return methodCall;
		}
		else return fCollectionName;
	}
	private String[] addProposalsForElement() {
		ICompilationUnit icu= getCompilationUnit();
		IJavaProject javaProject= icu.getJavaProject();
		int dimensions= fOldCollectionTypeBinding.getDimensions() - 1;
		String[] proposals= StubUtility.getLocalNameSuggestions(javaProject, ConvertForLoopProposal.ELEMENT_KEY_REFERENCE,
			dimensions, getUsedVariableNames());
		for (int i= 0; i < proposals.length; i++) {
			String proposal= proposals[i];
			addLinkedPositionProposal(ConvertForLoopProposal.ELEMENT_KEY_REFERENCE, proposal, null);
		}
		
		String[] shortProposals= StubUtility.getLocalNameSuggestions(javaProject, ELEMENT_KEY_REFERENCE.substring(0, 1),
			dimensions, getUsedVariableNames());
		for (int i= 0; i < proposals.length; i++) {
			String proposal= shortProposals[i];
			addLinkedPositionProposal(ConvertForLoopProposal.ELEMENT_KEY_REFERENCE, proposal, null);