private void visitLoopBody(@NotNull PsiStatement loopBody,
                               @NotNull Set<PsiVariable> nonFinalVariables,
                               @NotNull Set<PsiVariable> declaredVariables) {
      PsiStatement[] statements = getStatements(loopBody);
      if (!hasMissingBreakCandidates(statements)) return;
      PsiIfStatement ifStatementMissingBreak = null;
      for (PsiStatement statement : statements) {
        if (statement instanceof PsiDeclarationStatement) {
          collectVariables((PsiDeclarationStatement)statement, loopBody, nonFinalVariables, declaredVariables);
        }
        else if (statement instanceof PsiIfStatement ifStatement) {
          PsiExpression condition = ifStatement.getCondition();
          if (condition == null || mayHaveOutsideOfLoopSideEffects(condition, declaredVariables)) {
            return;
          }
          if (isMissingBreak(ifStatement, nonFinalVariables, declaredVariables)) {
            if (ifStatementMissingBreak != null) return;
            ifStatementMissingBreak = ifStatement;
            continue;
          }
        }
        if (mayHaveOutsideOfLoopSideEffects(statement, declaredVariables)) return;
      }
      if (ifStatementMissingBreak == null) return;
      registerError(ifStatementMissingBreak.getFirstChild());
    }
private void visitLoopBody(@NotNull PsiStatement loopBody,
                               @NotNull Set<PsiVariable> nonFinalVariables,
                               @NotNull Set<PsiVariable> declaredVariables)