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
}
	}
	/**
	 * @param name message to be displayed in the quick fix popup
	 * @param cu CompilationUnit containing the For Statement
	 * @param forStatement The For statement to be converted
	 * @param relevance
	 * @param image
	 */
	public ConvertForLoopProposal(String name, ICompilationUnit cu, ForStatement forStatement, int relevance, Image image) {
		super(name, cu, null, relevance, image);
		this.fOldForStatement= forStatement;
		fAst= fOldForStatement.getAST();
	}
	/**
	 * Check if the OldFor can be converted to Enhanced For. Unless all
	 * preconditions hold true, there is no reason for this QuickAssist to pop
	 * up.
	 * 
	 * @return true if all preconditions (arrayCanBeInferred &&
	 *         arrayOrIndexNotAssignedTo indexNotReferencedOutsideInferredArray &&
	 *         onlyOneIndexUsed && additionalTempsNotReferenced) are satisfied
	 */
	public boolean satisfiesPreconditions() {
		return is5_0_Source() 
			&& arrayCanBeInferred() 
			&& typeBindingsAreNotNull()
			&& bodySatifiesPreconditions()		
			&& initializersSatisfyPreconditions() 
			&& updatersSatifyPreconditions();