boolean (PsiExpression memberAccessExpression, @NotNull PsiMember member) { if (member.hasModifierProperty(PsiModifier.STATIC)) { return false; } final PsiClass memberClass = member.getContainingClass(); if (memberClass == null) { return false; } PsiClass containingClass = ClassUtils.getContainingClass(memberAccessExpression); if (InheritanceUtil.isInheritorOrSelf(containingClass, memberClass, true)) { // unqualified this. return true; } do { containingClass = ClassUtils.getContainingClass(containingClass); } while (containingClass != null && !InheritanceUtil.isInheritorOrSelf(containingClass, memberClass, true)); // qualified this needed, which is not possible on anonymous class. return containingClass != null && !(containingClass instanceof PsiAnonymousClass); }