void (PsiReferenceExpression expr, ProblemsHolder holder) { JavaResolveResult result = expr.advancedResolve(false); PsiElement resolved = result.getElement(); if (!(resolved instanceof PsiMember)) return; PsiExpression qualifierExpression = expr.getQualifierExpression(); if (qualifierExpression == null) 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; //don't report warnings on compilation errors PsiClass containingClass = ((PsiMember)resolved).getContainingClass(); if (containingClass != null && containingClass.isInterface()) return; if (containingClass instanceof PsiAnonymousClass) return; String description = JavaErrorBundle.message("static.member.accessed.via.instance.reference", JavaHighlightUtil.formatType(qualifierExpression.getType()), HighlightMessageUtil.getSymbolName(resolved, result.getSubstitutor())); holder.registerProblem(expr, description, createAccessStaticViaInstanceFix(expr, result)); }