Bug 84983 [typing] imports disappear
I20050209-0800 + JDT UI from HEAD 1. open a CU with several imports 2. enable folding (ensure imports are folded) 3. remove code so that first import is no longer needed 4. run Organize Imports ==> all imports are gone 5. close and re-open the editor ==> imports are back
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/folding/DefaultJavaFoldingStructureProvider.java
private Map createAnnotationMap(IAnnotationModel model) {
		Map map= new HashMap();
		Iterator e= model.getAnnotationIterator();
		while (e.hasNext()) {
			Object annotation= e.next();
			if (annotation instanceof JavaProjectionAnnotation) {
				JavaProjectionAnnotation java= (JavaProjectionAnnotation) annotation;
				Position position= model.getPosition(java);
				List list= (List) map.get(java.getElement());
				if (list == null) {
					list= new ArrayList(2);
					map.put(java.getElement(), list);
				}
				list.add(new Object[] {java, position});
			}
		}
		
		Comparator comparator= new Comparator() {
			public int compare(Object o1, Object o2) {
				return ((Position)((Object[]) o1)[1]).getOffset() - ((Position)((Object[]) o2)[1]).getOffset();
			}
		};
		for (Iterator it= map.values().iterator(); it.hasNext();) {
			List list= (List) it.next();
			Collections.sort(list, comparator);
		}
		return map;
	}
}