void (@NotNull PsiForStatement statement) { super.visitForStatement(statement); PsiStatement body = statement.getBody(); PsiStatement[] statements = ControlFlowUtils.unwrapBlock(body); PsiMethodCallExpression maybeSetCall = getLastMethodCall(statements); if (!LIST_SET.test(maybeSetCall)) return; if (dontWarnInCaseOfMultilineLambda && isMultilineLambda(body, statements)) return; PsiExpression index = PsiUtil.skipParenthesizedExprDown(maybeSetCall.getArgumentList().getExpressions()[0]); CountingLoop countingLoop = CountingLoop.from(statement); if (countingLoop == null) return; PsiLocalVariable counter = countingLoop.getCounter(); if (countingLoop.isIncluding() || countingLoop.isDescending() || !ExpressionUtils.isZero(countingLoop.getInitializer()) || !ExpressionUtils.isReferenceTo(index, counter)) { return; } IndexedContainer container = IndexedContainer.fromLengthExpression(countingLoop.getBound()); if (container == null) return; List<PsiReferenceExpression> references = VariableAccessUtils.getVariableReferences(counter, body); if (!ContainerUtil.all(references, reference -> reference == index || container.extractGetExpressionFromIndex(reference) != null)) { return; } if (isRedundantOperation(maybeSetCall.getArgumentList().getExpressions()[1], body, countingLoop, container)) return; if (!container.isQualifierEquivalent(ExpressionUtils.getEffectiveQualifier(maybeSetCall.getMethodExpression()))) return; Predicate<PsiVariable> variableAllowedPredicate = v -> PsiEquivalenceUtil.areElementsEquivalent(v, counter); if (!LambdaGenerationUtil.canBeUncheckedLambda(body, variableAllowedPredicate)) return; holder.registerProblem(statement.getFirstChild(), QuickFixBundle.message("java.8.list.replaceall.inspection.description"), new ReplaceWithReplaceAllQuickFix()); }