IDEA-91844 Groovy: "Method may be static" inspection doesn't report methods which have references to static members from other classes

This commit is contained in:
Max Medvedev
2012-09-21 13:28:24 +04:00
parent a00f3b097d
commit 2a6abe716c
2 changed files with 20 additions and 0 deletions
@@ -130,6 +130,7 @@ public class GrMethodMayBeStaticInspection extends BaseInspection {
GroovyPsiElement resolveContext = result.getCurrentFileResolveContext();
if (resolveContext != null) return;
if (element instanceof PsiClass && ((PsiClass)element).getContainingClass() == null) return;
if (element instanceof PsiMember && !((PsiMember)element).hasModifierProperty(PsiModifier.STATIC)) {
myMay = false;
}
@@ -70,4 +70,23 @@ class A {
myFixture.enableInspections(GrMethodMayBeStaticInspection)
myFixture.checkHighlighting(true, false, false)
}
void testOtherClasses() {
myFixture.with {
addFileToProject('Fooo.groovy', '''\
class Fooo {
static def foo() {}
}
''')
configureByText('_.groovy', '''\
class Bar {
static def abc()
def bar() {
abc()
Fooo.foo()
}
}
''')
}
}
}