void (PsiLoopStatement loop, ControlFlow bodyFlow, @NotNull ProblemsHolder holder) { Collection<PsiVariable> variables = ControlFlowUtil.getWrittenVariables(bodyFlow, 0, bodyFlow.getSize(), true); if (variables.isEmpty()) return; List<PsiReferenceExpression> reads = ControlFlowUtil.getReadBeforeWrite(bodyFlow); if (StreamEx.of(reads).map(PsiReferenceExpression::resolve).select(PsiVariable.class) .noneMatch(v -> v.hasModifierProperty(PsiModifier.VOLATILE) || variables.contains(v))) { holder.registerProblem(loop.getFirstChild(), JavaBundle.message("inspection.idempotent.loop.body")); } }