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
if (result != null && result.equals(fIterator))
									return replace(node);
							}
						}
						return super.visit(node);
					}
					public final boolean visit(final SimpleName node) {
						if (fElement != null) {
							final IBinding binding= node.resolveBinding();
							if (binding != null && binding.equals(fElement)) {
								final Statement parent= (Statement) ASTNodes.getParent(node, Statement.class);
								if (parent != null && list.getRewrittenList().contains(parent))
									addLinkedPosition(rewrite.track(node), false, GROUP_ELEMENT);
							}
						}
						return false;
					}
				});
			}
			statement.setBody((Statement) rewrite.createMoveTarget(body));
		}
		final SingleVariableDeclaration declaration= fAst.newSingleVariableDeclaration();
		final SimpleName simple= fAst.newSimpleName(name);
		addLinkedPosition(rewrite.track(simple), true, GROUP_ELEMENT);
		declaration.setName(simple);
		declaration.setType(getImportRewrite().addImport(getIterableType(fIterator.getType()), fAst));
		statement.setParameter(declaration);
		statement.setExpression(getExpression(rewrite));
		rewrite.replace(fStatement, statement, null);
		return rewrite;