Bug 66234 [projection] Revert file sometimes does not display the imports
I was able to recreate the scenario, I have a Java file in a Java project as /* * Created on Jun 8, 2004 * * TODO To change the template for this generated file go to * Window - Preferences - Java - Code Style - Code Templates */ package com; import java.net.URL; import java.util.Date; /** * @author admin * * TODO To change the template for this generated type comment go to * Window - Preferences - Java - Code Style - Code Templates */ public class Test { Date xyz; URL abc; } I open it in the editor, delete the keyword 'package' so that that line only says com. Now I right click on file and select 'Revert File'. Notice that the imports list disappears. This is in M9.
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditor.java
int position= widgetOffset2ModelOffset(viewer, viewer.getTextWidget().getCaretOffset());
			if (position == -1)
				return;
			
			int previous= findPreviousPosition(position);
			if (previous != BreakIterator.DONE) {
				setCaretPosition(previous);
				getTextWidget().showSelection();
				fireSelectionChanged();
			}
				
		}
		/**
		 * Finds the previous position before the given position.
		 * 
		 * @param position the current position
		 * @return the previous position
		 */
		protected int findPreviousPosition(int position) {
			ISourceViewer viewer= getSourceViewer();
			int widget= -1;
			while (position != BreakIterator.DONE && widget == -1) { 
				position= fIterator.preceding(position);
				if (position != BreakIterator.DONE)
					widget= modelOffset2WidgetOffset(viewer, position);
			}
			return position;
		}
		/**
		 * Sets the caret position to the sub-word boundary given with <code>position</code>.