Project: JDT
Bug 175498 [organize imports] Organize imports adds useless static imports
Reported: 2007-02-26 04:16:35 | Status: resolved fixed

package sample; public class Test<T> { public static enum TestEnum { V1, V2 } public void test(final TestEnum value) { switch (value) { case V1: case V2: } } } The following imports are added by 'Organize imports': import static sample.Test.TestEnum.V1; import static sample.Test.TestEnum.V2; These imports are useless, they are correctly reported as unused, but they get added anyway. Moreover, they are static imports and I was told that no static imports should be added by 'Organize imports' (#165069). I have observed that this issue is triggered by the combination of: - the case clauses of switch statement, - the fact that the TestEnum enum is embedded, - the fact that the Test class is generic.

Files changed in fix:
org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/ImportOrganizeTest.java org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/dom/ScopeAnalyzer.java