void (@NotNull PsiForStatement statement) { PsiStatement body = statement.getBody(); if (body == null) return; Set<PsiVariable> nonFinalVariables = new HashSet<>(); Set<PsiVariable> declaredVariables = new HashSet<>(); PsiDeclarationStatement initialization = tryCast(statement.getInitialization(), PsiDeclarationStatement.class); if (initialization != null) collectVariables(initialization, statement, nonFinalVariables, declaredVariables); PsiStatement update = statement.getUpdate(); if (update != null && mayHaveOutsideOfLoopSideEffects(update, declaredVariables)) return; PsiExpression condition = statement.getCondition(); if (condition != null && mayHaveOutsideOfLoopSideEffects(condition, declaredVariables)) return; visitLoopBody(body, nonFinalVariables, declaredVariables); }