boolean (final ArrayList<? extends PsiElement> candidates, final Match match) { final PsiElement codeFragment = ControlFlowUtil.findCodeFragment(candidates.get(0)); try { final ControlFlow controlFlow = ControlFlowFactory.getInstance(codeFragment.getProject()).getControlFlow(codeFragment, new LocalsControlFlowPolicy(codeFragment), false); int startOffset; int i = 0; do { startOffset = controlFlow.getStartOffset(candidates.get(i++)); } while(startOffset < 0 && i < candidates.size()); int endOffset; int j = candidates.size() - 1; do { endOffset = controlFlow.getEndOffset(candidates.get(j--)); } while(endOffset < 0 && j >= 0); final IntList exitPoints = new IntArrayList(); ControlFlowUtil.findExitPointsAndStatements(controlFlow, startOffset, endOffset, exitPoints, ControlFlowUtil.DEFAULT_EXIT_STATEMENTS_CLASSES); final PsiVariable[] outVariables = ControlFlowUtil.getOutputVariables(controlFlow, startOffset, endOffset, exitPoints.toIntArray()); if (outVariables.length > 0) { if (outVariables.length == 1) { ReturnValue returnValue = match.getReturnValue(); if (returnValue == null) { returnValue = myReturnValue; } if (returnValue instanceof GotoReturnValue || returnValue instanceof ConditionalReturnStatementValue && ((ConditionalReturnStatementValue)returnValue).isEmptyOrConstantExpression()) { return false; } if (returnValue instanceof VariableReturnValue) { final ReturnValue value = match.getOutputVariableValue(((VariableReturnValue)returnValue).getVariable()); if (value != null) { if (value.isEquivalent(new VariableReturnValue(outVariables[0]))) return false; if (value instanceof ExpressionReturnValue) { final PsiExpression expression = ((ExpressionReturnValue)value).getExpression(); if (expression instanceof PsiReferenceExpression) { final PsiElement variable = ((PsiReferenceExpression)expression).resolve(); return variable == null || !PsiEquivalenceUtil.areElementsEquivalent(variable, outVariables[0]); } } } } } return true; } } catch (AnalysisCanceledException ignored) { } return false; }