boolean (PsiThisExpression expression, PsiAssignmentExpression assignmentExpression) { final PsiExpression rhs = assignmentExpression.getRExpression(); if (!expression.equals(rhs)) { return false; } final PsiExpression lExpression = assignmentExpression.getLExpression(); if (!(lExpression instanceof PsiReferenceExpression leftExpression)) { return false; } final PsiElement element = leftExpression.resolve(); if (!(element instanceof PsiField field)) { return false; } if (field.hasModifierProperty(PsiModifier.STATIC)) { return true; } final PsiClass assignmentClass = ClassUtils.getContainingClass(assignmentExpression); final PsiClass fieldClass = field.getContainingClass(); return !(assignmentClass == null || fieldClass == null || assignmentClass.isInheritor(fieldClass, true) || PsiTreeUtil.isAncestor(assignmentClass, fieldClass, false)); }