Bug 113770 [organize import] generates syntactically incorrect static import
In very few cases, "organize import" generates an invalid static import. Note that the following compiable example must be placed in *two* separate files. When organizing imports for the first file, it generates the invalid import "import static EclipseBugOrganizeStaticImport.logger;". ----------------------------------------------- public class EclipseBugOrganizeStaticImport { private static String logger; public void startGenerator() { new MyRunnableImpl() { @Override public void run() { try { // } catch (Exception e) { logger.toString(); } } }; } } ---------------------------------------------- package de.ingo_homann.test; public class MyRunnableImpl implements Runnable { private static String logger; public void run() { // } }
org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/ImportOrganizeTest.java
buf.append("                C1 c1;\n");
		buf.append("                C2 c2;\n");
		buf.append("            }\n");
		buf.append("        }\n");
		buf.append("    }\n");
		buf.append("}\n");		
		ICompilationUnit cu2= pack2.createCompilationUnit("A.java", buf.toString(), false, null);
		String[] order= new String[0];
		IChooseImportQuery query= createQuery("A", new String[] {}, new int[] {});
	
		OrganizeImportsOperation op= createOperation(cu2, order, 99, false, true, true, query);
		op.run(null);
		
		assertImports(cu2, new String[] {
			"test1.C", 
			"test1.C.C1.C2",
			"test2.A.A1.A2", 
			"test2.A.A1.A2.A3"
		});
	}
	
	
	public void testClearImports() throws Exception {
		IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
		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 C {\n");
		buf.append("}\n");