IDEA-120028 Groovy: "Optimize imports": static keyword is removed from unresolved imports

This commit is contained in:
Max Medvedev
2014-01-31 18:29:59 +04:00
parent 5fcedc10ec
commit de32aab909
6 changed files with 27 additions and 4 deletions
@@ -227,16 +227,23 @@ public class GroovyImportOptimizer implements ImportOptimizer {
usedImports.add(anImport);
}
final String className = getImportReferenceText(anImport);
final String symbolName = getImportReferenceText(anImport);
if (anImport.isAliasedImport()) {
if (aliased != null) {
aliased.put(className, importedName);
aliased.put(symbolName, importedName);
}
}
else {
if (importedClasses != null) {
importedClasses.add(className);
if (anImport.isStatic()) {
if (staticallyImportedMembers != null) {
staticallyImportedMembers.add(symbolName);
}
}
else {
if (importedClasses != null) {
importedClasses.add(symbolName);
}
}
}
}
@@ -150,6 +150,8 @@ public class OptimizeImportsTest extends LightGroovyTestCase {
public void testDontRemoveRedImports5() { doTest(); }
public void testDontRemoveRedImports6() { doTest(); }
public void testDontRemoveRedImports7() { doTest(); }
public void testDontRemoveRedImports8() { doTest(); }
public void testDontRemoveRedImports9() { doTest(); }
public void testRemoveSamePackaged() {
myFixture.addClass("package foo.bar; public class Aaaa {}");
@@ -0,0 +1,4 @@
import static abc.X.foo
import static abc.X.bar
print foo()
@@ -0,0 +1,3 @@
import static abc.X.foo
print foo()
@@ -0,0 +1,4 @@
import static abc.X.foo as bar
import static abc.X.baz as xyz
print bar()
@@ -0,0 +1,3 @@
import static abc.X.foo as bar
print bar()