Bug 102846 [quick fix] Convert to enhanced for loop does not remove obsolete import
I20050627-1435 (3.1) The 'Convert to enhanced for loop' quick fix does not remove the obsolete import java.util.Iterator in this example: import java.util.Iterator; import java.util.List; public class Try { public static void print(List<String> names) { for (Iterator iter= names.iterator(); iter.hasNext();) { String name= (String) iter.next(); System.out.println(name); } } }
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/ConvertIterableLoopProposal.java
}
		for (final Iterator iterator= names.iterator(); iterator.hasNext();)
			addLinkedPositionProposal(GROUP_ELEMENT, (String) iterator.next(), null);
		final Statement body= fStatement.getBody();
		if (body != null) {
			if (body instanceof Block) {
				final ListRewrite list= rewrite.getListRewrite(body, Block.STATEMENTS_PROPERTY);
				for (final Iterator iterator= fOccurrences.iterator(); iterator.hasNext();) {
					final Statement parent= (Statement) ASTNodes.getParent((ASTNode) iterator.next(), Statement.class);
					if (parent != null && list.getRewrittenList().contains(parent))
						list.remove(parent, null);
				}
				final String text= name;
				body.accept(new ASTVisitor() {
					private boolean replace(final Expression expression) {
						final SimpleName node= fAst.newSimpleName(text);
						rewrite.replace(expression, node, null);
						addLinkedPosition(rewrite.track(node), false, GROUP_ELEMENT);
						return false;
					}
					public final boolean visit(final MethodInvocation node) {
						final IMethodBinding binding= node.resolveMethodBinding();
						if (binding != null && (binding.getName().equals("next") || binding.getName().equals("nextElement"))) { 
							final Expression expression= node.getExpression();
							if (expression instanceof Name) {
								final IBinding result= ((Name) expression).resolveBinding();
								if (result != null && result.equals(fIterator))
									return replace(node);
							} else if (expression instanceof FieldAccess) {
								final IBinding result= ((FieldAccess) expression).resolveFieldBinding();