fully qualified class name should not be treated as instance access
authoranna <anna.kozlova@jetbrains.com>
Mon, 15 Feb 2010 10:51:12 +0000 (15 13:51 +0300)
committeranna <anna.kozlova@jetbrains.com>
Mon, 15 Feb 2010 14:30:35 +0000 (15 17:30 +0300)
java/java-impl/src/com/intellij/codeInspection/accessStaticViaInstance/AccessStaticViaInstance.java

index dd759bb..76795f2 100644 (file)
@@ -68,8 +68,11 @@ public class AccessStaticViaInstance extends BaseJavaLocalInspectionTool {
     PsiExpression qualifierExpression = expr.getQualifierExpression();
     if (qualifierExpression == null) return;
 
-    if (qualifierExpression instanceof PsiReferenceExpression && ((PsiReferenceExpression)qualifierExpression).resolve() instanceof PsiClass) {
-      return;
+    if (qualifierExpression instanceof PsiReferenceExpression) {
+      final PsiElement qualifierResolved = ((PsiReferenceExpression)qualifierExpression).resolve();
+      if (qualifierResolved instanceof PsiClass || qualifierResolved instanceof PsiPackage) {
+        return;
+      }
     }
     if (!((PsiMember)resolved).hasModifierProperty(PsiModifier.STATIC)) return;