AnalysisResult (@NotNull List<Instruction> subGraph, int start, int end) { int returnSources = 0; int regularSources = 0; int starImports = 0; int outerLoopBreaks = 0; int yieldExpressions = 0; for (Pair<Instruction, Instruction> edge : getOutgoingEdges(subGraph)) { final Instruction sourceInstruction = edge.getFirst(); final Instruction targetInstruction = edge.getSecond(); final PsiElement source = sourceInstruction.getElement(); final PsiElement target = targetInstruction.getElement(); final PyReturnStatement returnStatement = PsiTreeUtil.getParentOfType(source, PyReturnStatement.class, false); final boolean isExceptTarget = target instanceof PyExceptPart || target instanceof PyFinallyPart; if (returnStatement != null && CodeFragmentUtil.getPosition(returnStatement, start, end) == Position.INSIDE) { returnSources++; } else if (!isExceptTarget) { regularSources++; } } final Set<PsiElement> subGraphElements = getSubGraphElements(subGraph); for (PsiElement element : subGraphElements) { if (element instanceof PyFromImportStatement fromImportStatement) { if (fromImportStatement.getStarImportElement() != null) { starImports++; } } if (element instanceof PyContinueStatement || element instanceof PyBreakStatement) { final PyLoopStatement loopStatement = PyUtil.getCorrespondingLoop(element); if (loopStatement != null && !subGraphElements.contains(loopStatement)) { outerLoopBreaks++; } } if (element instanceof PyYieldExpression) { yieldExpressions++; } } return new AnalysisResult(starImports, returnSources, regularSources, outerLoopBreaks, yieldExpressions); }