Community
Participate
Working Groups
Member types imports are removed too aggressively. When using: import java.util.*; import java.util.Map.Entry; The latter one should not be removed as Entry could then not be resolved anymore in the compilation unit. This bug is now visible because java.util.* and java.util.Map.Entry are now within the same import group.
To reproduce, the 'Organize Imports' preference for number of needed imports must be set to something low, e.g. 0.
Created attachment 160089 [details] Proposed fix + regression test
I quickly glanced over the patch (didn't try it out). If I understood that right, ImportRewriteAnalyzer.ImportDeclEntry#getSimpleName() is now actually returning the typeQualifiedName, so it should be renamed. But I see a problem in ImportRewriteAnalyzer#evaluateStarImportConflicts(..) then, because there, the "simple" names are stored in simpleTypeNames, which is passed to a SearchEngine#searchAllTypeNames(..) method that only expects simple names.
(In reply to comment #3) > I quickly glanced over the patch (didn't try it out). If I understood that > right, ImportRewriteAnalyzer.ImportDeclEntry#getSimpleName() is now actually > returning the typeQualifiedName, so it should be renamed. I'll check that. > But I see a problem in ImportRewriteAnalyzer#evaluateStarImportConflicts(..) > then, because there, the "simple" names are stored in simpleTypeNames, which is > passed to a SearchEngine#searchAllTypeNames(..) method that only expects simple > names. Ok, I'll take a look. Thanks.
(In reply to comment #3) > I quickly glanced over the patch (didn't try it out). If I understood that > right, ImportRewriteAnalyzer.ImportDeclEntry#getSimpleName() is now actually > returning the typeQualifiedName, so it should be renamed. I would say it actually returns the type name inside the package. I create a new method called: getTypeQualifiedName(); > But I see a problem in ImportRewriteAnalyzer#evaluateStarImportConflicts(..) > then, because there, the "simple" names are stored in simpleTypeNames, which is > passed to a SearchEngine#searchAllTypeNames(..) method that only expects simple > names. I am using the new method only when computing the remaining imports for a group of imports and the threshold has been reached.
Created attachment 160106 [details] Proposed fix + regression test
Released for 3.6M6. Regression test added in: org.eclipse.jdt.core.tests.rewrite.describing.ImportRewriteTest#testAddImports5
*** Bug 304111 has been marked as a duplicate of this bug. ***
Verified for 3.6M6 using I20100307-2000 build.