boolean (@NotNull PsiElement place, @Nullable PsiClass targetClass) { if (place instanceof GrReferenceExpression) { GrQualifiedReference reference = (GrQualifiedReference)place; PsiElement qualifier = reference.getQualifier(); if (qualifier != null && !PsiUtil.isThisOrSuperRef(reference)) { if (PsiUtil.isInstanceThisRef(qualifier) || PsiUtil.isSuperReference(qualifier)) { return false; } else if (PsiUtil.isThisReference(qualifier)) { //instance 'this' already is processed. So it static 'this' return true; } return qualifier instanceof GrQualifiedReference && ResolveUtil.resolvesToClass(qualifier); } if (PsiUtil.isSuperReference(reference)) return false; //this reference should be checked as all other refs } PsiElement run = place; while (run != null && run != targetClass) { if (targetClass == null && run instanceof PsiClass) return false; if (run instanceof GrClosableBlock) return false; if (run instanceof PsiModifierListOwner && ((PsiModifierListOwner)run).hasModifierProperty(PsiModifier.STATIC)) return true; run = run.getParent(); } return false; }