Bug 81135 Organize Imports throws away annotation imports [5.0]
M4 test pass (I20041214-2000-gtk) 1. have this code: package com.example.m4testing; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; public class Test { @Documented @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.ANNOTATION_TYPE) static @interface ThrowAwayMethod { } } 2. press Ctrl+shift+O -> imported anntations disappear Note that Ctrl+Shift+M on a single annotation works as expected.
org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/ImportOrganizeTest.java
IPackageFragment pack1= sourceFolder.createPackageFragment("test1", false, null);
		StringBuffer buf= new StringBuffer();
		buf.append("package test1;\n");
		buf.append("import java.util.Vector;\n");
		buf.append("public class A {\n");
		buf.append("    public void foo(Vector vec) {\n");
		buf.append("        HashMap map;\n");
		buf.append("        /*b*/\n");
		buf.append("        Iterator iter= ((Collection) vec).iterator();\n");
		buf.append("        /*e*/\n");
		buf.append("    }\n");
		buf.append("}\n");	
		String content= buf.toString();
		ICompilationUnit cu= pack1.createCompilationUnit("A.java", content, false, null);
		int start= content.indexOf("/*b*/");
		int end= content.indexOf("/*e*/");
		Region sel= new Region(start, end);
		String[] order= new String[] { };
		int threshold= 99;
				
		ImportsStructure structure= new ImportsStructure(cu, order, threshold, true);
		OrganizeImportsOperation op= new OrganizeImportsOperation(structure, sel, true, true, null);
		op.run(null);
		buf= new StringBuffer();
		buf.append("package test1;\n");
		buf.append("import java.util.Collection;\n");
		buf.append("import java.util.Iterator;\n");
		buf.append("import java.util.Vector;\n");
		buf.append("public class A {\n");