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
ICompilationUnit cu= (ICompilationUnit) fJProject1.findElement(new Path("junit/runner/BaseTestRunner.java"));
		assertNotNull("BaseTestRunner.java", cu);
		
		IPackageFragmentRoot root= (IPackageFragmentRoot)cu.getParent().getParent();
		IPackageFragment pack= root.createPackageFragment("mytest", true, null);
		
		ICompilationUnit colidingCU= pack.getCompilationUnit("TestListener.java");
		colidingCU.createType("public abstract class TestListener {\n}\n", null, true, null);
		
		
		String[] order= new String[0];
		IChooseImportQuery query= createQuery("BaseTestRunner", new String[] { "junit.framework.TestListener" }, new int[] { 2 });
		
		OrganizeImportsOperation op= createOperation(cu, order, 99, false, true, true, query);
		op.run(null);
		
		assertImports(cu, new String[] {
			"java.io.BufferedReader",
			"java.io.File",
			"java.io.FileInputStream",
			"java.io.FileOutputStream",
			"java.io.IOException",
			"java.io.InputStream",
			"java.io.PrintWriter",
			"java.io.StringReader",
			"java.io.StringWriter",
			"java.lang.reflect.InvocationTargetException",
			"java.lang.reflect.Method",
			"java.lang.reflect.Modifier",
			"java.text.NumberFormat",