boolean (@NotNull PsiMethod method) { if (DumbService.isDumb(method.getProject())) return false; PsiCodeBlock body = method.getBody(); if (body == null || body.getLBrace() == null || body.getRBrace() == null) return false; PsiStatement[] statements = body.getStatements(); if (statements.length == 0) return false; PsiStatement statement = statements[0]; if (PropertyUtilBase.isSimplePropertyGetter(method)) { if (statement instanceof PsiReturnStatement) { return ((PsiReturnStatement)statement).getReturnValue() instanceof PsiReferenceExpression; } return false; } // builder-style setter? if (statements.length > 1 && !(statements[1] instanceof PsiReturnStatement)) return false; // any setter? if (statement instanceof PsiExpressionStatement) { PsiExpression expr = ((PsiExpressionStatement)statement).getExpression(); if (expr instanceof PsiAssignmentExpression) { PsiExpression lhs = ((PsiAssignmentExpression)expr).getLExpression(); PsiExpression rhs = ((PsiAssignmentExpression)expr).getRExpression(); return lhs instanceof PsiReferenceExpression && rhs instanceof PsiReferenceExpression && !((PsiReferenceExpression)rhs).isQualified() && PropertyUtilBase.isSimplePropertySetter(method); // last check because it can perform long return type resolve } } return false; }