boolean (final PsiReturnStatement patternReturnStatement, PsiElement candidate, List<PsiElement> candidates, Match match) { if (candidate instanceof PsiExpressionStatement) { final PsiExpression expression = ((PsiExpressionStatement)candidate).getExpression(); if (expression instanceof PsiAssignmentExpression) { final PsiExpression returnValue = patternReturnStatement.getReturnValue(); final PsiExpression rExpression = ((PsiAssignmentExpression)expression).getRExpression(); if (!matchPattern(returnValue, rExpression, candidates, match)) return false; final PsiExpression lExpression = ((PsiAssignmentExpression)expression).getLExpression(); return match.registerReturnValue(new ExpressionReturnValue(lExpression)); } else return false; } else if (candidate instanceof PsiDeclarationStatement) { final PsiElement[] declaredElements = ((PsiDeclarationStatement)candidate).getDeclaredElements(); if (declaredElements.length != 1) return false; if (!(declaredElements[0] instanceof PsiVariable variable)) return false; if (!matchPattern(patternReturnStatement.getReturnValue(), variable.getInitializer(), candidates, match)) return false; return match.registerReturnValue(new VariableReturnValue(variable)); } else if (candidate instanceof PsiReturnStatement) { final PsiExpression returnValue = PsiUtil.skipParenthesizedExprDown(((PsiReturnStatement)candidate).getReturnValue()); if (myMultipleExitPoints) { return match.registerReturnValue(new ConditionalReturnStatementValue(returnValue)); } else { final PsiElement classOrLambda = PsiTreeUtil.getContextOfType(returnValue, PsiClass.class, PsiLambdaExpression.class); final PsiElement commonParent = PsiTreeUtil.findCommonParent(match.getMatchStart(), match.getMatchEnd()); if (classOrLambda == null || !PsiTreeUtil.isAncestor(commonParent, classOrLambda, false)) { if (returnValue != null && !match.registerReturnValue(ReturnStatementReturnValue.INSTANCE)) return false; //do not register return value for return; statement } return matchPattern(PsiUtil.skipParenthesizedExprDown(patternReturnStatement.getReturnValue()), returnValue, candidates, match); } } else return false; }