boolean (PsiStatement statement, PsiMethod method) { if (statement == null) { return false; } if (statement instanceof PsiBreakStatement || statement instanceof PsiContinueStatement || statement instanceof PsiThrowStatement || statement instanceof PsiEmptyStatement || statement instanceof PsiAssertStatement) { return false; } else if (statement instanceof PsiExpressionListStatement expressionListStatement) { final PsiExpressionList expressionList = expressionListStatement.getExpressionList(); if (expressionList == null) { return false; } final PsiExpression[] expressions = expressionList.getExpressions(); for (final PsiExpression expression : expressions) { if (expressionDefinitelyRecurses(expression, method)) { return true; } } return false; } else if (statement instanceof PsiExpressionStatement expressionStatement) { final PsiExpression expression = expressionStatement.getExpression(); return expressionDefinitelyRecurses(expression, method); } else if (statement instanceof PsiDeclarationStatement declaration) { final PsiElement[] declaredElements = declaration.getDeclaredElements(); for (final PsiElement declaredElement : declaredElements) { if (declaredElement instanceof PsiLocalVariable variable) { final PsiExpression initializer = variable.getInitializer(); if (expressionDefinitelyRecurses(initializer, method)) { return true; } } } return false; } else if (statement instanceof PsiYieldStatement) { return expressionDefinitelyRecurses(((PsiYieldStatement)statement).getExpression(), method); } else if (statement instanceof PsiReturnStatement returnStatement) { final PsiExpression returnValue = returnStatement.getReturnValue(); if (returnValue != null) { if (expressionDefinitelyRecurses(returnValue, method)) { return true; } } return false; } else if (statement instanceof PsiForStatement) { return forStatementDefinitelyRecurses((PsiForStatement) statement, method); } else if (statement instanceof PsiForeachStatement) { return foreachStatementDefinitelyRecurses( (PsiForeachStatement)statement, method); } else if (statement instanceof PsiWhileStatement) { return whileStatementDefinitelyRecurses( (PsiWhileStatement)statement, method); } else if (statement instanceof PsiDoWhileStatement) { return doWhileStatementDefinitelyRecurses( (PsiDoWhileStatement)statement, method); } else if (statement instanceof PsiSynchronizedStatement) { final PsiCodeBlock body = ((PsiSynchronizedStatement)statement) .getBody(); return codeBlockDefinitelyRecurses(body, method); } else if (statement instanceof PsiBlockStatement) { final PsiCodeBlock codeBlock = ((PsiBlockStatement)statement) .getCodeBlock(); return codeBlockDefinitelyRecurses(codeBlock, method); } else if (statement instanceof PsiLabeledStatement) { return labeledStatementDefinitelyRecurses( (PsiLabeledStatement)statement, method); } else if (statement instanceof PsiIfStatement) { return ifStatementDefinitelyRecurses( (PsiIfStatement)statement, method); } else if (statement instanceof PsiTryStatement) { return tryStatementDefinitelyRecurses( (PsiTryStatement)statement, method); } else if (statement instanceof PsiSwitchStatement) { return switchStatementDefinitelyRecurses( (PsiSwitchStatement)statement, method); } else { // unknown statement type return false; } }