diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/toplevel/imports/GrImportStatementImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/toplevel/imports/GrImportStatementImpl.java index a60ee5b6b8fb..cbe35e56a0b9 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/toplevel/imports/GrImportStatementImpl.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/toplevel/imports/GrImportStatementImpl.java @@ -65,20 +65,23 @@ public class GrImportStatementImpl extends GroovyPsiElementImpl implements GrImp if (isOnDemand()) { GrCodeReferenceElement ref = getImportReference(); if (ref != null) { - String qName = PsiUtil.getQualifiedReferenceText(ref); - if (qName != null) { - if (!isStatic()) { + if (isStatic()) { + final PsiElement resolved = ref.resolve(); + if (resolved instanceof PsiClass) { + final PsiClass clazz = (PsiClass)resolved; + if (clazz != null) { + if (!processAllMembers(processor, clazz)) return false; + } + } + } + else { + String qName = PsiUtil.getQualifiedReferenceText(ref); + if (qName != null) { PsiPackage aPackage = facade.findPackage(qName); if (aPackage != null) { if (!aPackage.processDeclarations(processor, state, lastParent, place)) return false; } } - else { - final PsiClass clazz = facade.findClass(qName, getResolveScope()); - if (clazz != null) { - if (!processAllMembers(processor, clazz)) return false; - } - } } } } diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/ResolveClassTest.java b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/ResolveClassTest.java index 4e2cda1e9c82..6bdf94400435 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/ResolveClassTest.java +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/ResolveClassTest.java @@ -113,6 +113,13 @@ public class ResolveClassTest extends GroovyResolveTestCase { assertEquals("java.util.ArrayList", ((PsiClass)resolved).getQualifiedName()); } + public void testNotQualifiedStaticImport() throws Exception { + myFixture.addFileToProject("foo/A.groovy", "package foo \nclass Foo{ }"); + PsiReference ref = configureByFile("notQualifiedStaticImport/Test.groovy"); + final PsiElement resolved = ref.resolve(); + assertInstanceOf(resolved, PsiClass.class); + } + private void doTest() throws Exception { doTest(getTestName(true) + "/" + getTestName(false) + ".groovy"); } diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/ResolvePropertyTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/ResolvePropertyTest.groovy index dcc95e8add0d..40df6e79ffb6 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/ResolvePropertyTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/ResolvePropertyTest.groovy @@ -441,7 +441,7 @@ print new Foo().foo""") def resolved = ref.resolve(); assertInstanceOf resolved, GrAccessorMethod.class } - + public void testPropertyAndFieldDeclarationWithSuperClass4() { myFixture.configureByText("a.groovy", """ class Bar{ @@ -500,7 +500,7 @@ setBar(2) assertNull resolved } - public void resolvePropertyInCallExpression() { + public void testPropertyInCallExpression() { myFixture.configureByText("a.groovy", """ class Foo { def foo = { @@ -518,4 +518,15 @@ new Foo().foo(2)""" assertInstanceOf resolved, GrAccessorMethod } + + public void testPropertyImportedOnDemand() { + myFixture.addFileToProject("foo/A.groovy", 'package foo; class Foo {static def foo}') + myFixture.configureByText("B.groovy", """package foo +import static Foo.* +print foo""") + + def ref = findReference() + def resolved = ref.resolve() + assertInstanceOf(resolved, GrAccessorMethod) + } } \ No newline at end of file diff --git a/plugins/groovy/testdata/resolve/class/notQualifiedStaticImport/Test.groovy b/plugins/groovy/testdata/resolve/class/notQualifiedStaticImport/Test.groovy new file mode 100644 index 000000000000..e93ddb014110 --- /dev/null +++ b/plugins/groovy/testdata/resolve/class/notQualifiedStaticImport/Test.groovy @@ -0,0 +1,3 @@ +package foo + +import static Foo.* \ No newline at end of file