boolean (@NotNull PsiElement element) { PsiMethod method = PsiTreeUtil.getParentOfType(element, PsiMethod.class); if (method == null) return false; final PsiCodeBlock body = method.getBody(); if (body == null) { return false; } final PsiStatement[] statements = body.getStatements(); if (statements.length != 1) { return false; } final PsiStatement statement = statements[0]; if (!(statement instanceof PsiReturnStatement)) { return false; } final PsiExpression value = ((PsiReturnStatement)statement).getReturnValue(); if (!(value instanceof PsiReferenceExpression reference)) { return false; } final PsiExpression qualifier = reference.getQualifierExpression(); if (qualifier != null && !"this".equals(qualifier.getText())) { return false; } final PsiElement referent = reference.resolve(); if (referent == null) { return false; } if (!(referent instanceof PsiField)) { return false; } return Comparing.equal(((PsiField)referent).getContainingClass(), method.getContainingClass()); }