Bug 20424 Autocompletion "Iterate through Collection" should add "import java.util.Iterator"
I use autocompletion to generate an iteration through a collection. So this is the kind of code I'm getting: for (Iterator iter = myCollection.iterator(); iter.hasNext();) { type element = (type) iter.next(); However, autocompletion leaves my .java file without the neccessary import java.util.Iterator; required for all of this to make sense. I feel it's not as "auto" and not as "complete" as it could be (if you pardon the pun).
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/template/TemplateProposal.java
/*
	 * @see ICompletionProposal#apply(IDocument)
	 */
	public void apply(IDocument document) {
	    try {	        
		    if (fTemplateBuffer == null)
				fTemplateBuffer= fContext.evaluate(fTemplate);
			int start= fRegion.getOffset();
			int end= fRegion.getOffset() + fRegion.getLength();
			
			
			String templateString= fTemplateBuffer.getString();	
			document.replace(start, end - start, templateString);	
			
			LinkedPositionManager manager= new LinkedPositionManager(document);
			TemplatePosition[] variables= fTemplateBuffer.getVariables();
			for (int i= 0; i != variables.length; i++) {
				TemplatePosition variable= variables[i];
				if (variable.isResolved())
					continue;
				
				int[] offsets= variable.getOffsets();
				int length= variable.getLength();
				
				for (int j= 0; j != offsets.length; j++)
					manager.addPosition(offsets[j] + start, length);
			}
			
			LinkedPositionUI editor= new LinkedPositionUI(fViewer, manager);
			editor.setFinalCaretOffset(getCaretOffset(fTemplateBuffer) + start);