void (@NotNull PsiForeachStatement loop) { if (DO_NOT_HIGHLIGHT_LOOP && !isOnTheFly) return; PsiMethodCallExpression call = ObjectUtils.tryCast(PsiUtil.skipParenthesizedExprDown(loop.getIteratedValue()), PsiMethodCallExpression.class); PsiParameter parameter = loop.getIterationParameter(); if (MAP_ENTRY_SET.test(call) && LambdaGenerationUtil.canBeUncheckedLambda(loop.getBody()) && allUsagesAllowed(parameter)) { ProblemHighlightType type = DO_NOT_HIGHLIGHT_LOOP ? ProblemHighlightType.INFORMATION : ProblemHighlightType.GENERIC_ERROR_OR_WARNING; boolean wholeStatement = isOnTheFly && (DO_NOT_HIGHLIGHT_LOOP || InspectionProjectProfileManager.isInformationLevel(getShortName(), loop)); TextRange range; PsiJavaToken rParenth = loop.getRParenth(); PsiElement firstChild = loop.getFirstChild(); PsiElement toHighlight; if (wholeStatement && rParenth != null) { toHighlight = loop; range = new TextRange(firstChild.getStartOffsetInParent(), rParenth.getStartOffsetInParent() + 1); } else { toHighlight = firstChild; range = new TextRange(0, firstChild.getTextLength()); } holder.registerProblem(toHighlight, JavaAnalysisBundle.message("inspection.can.be.replaced.with.message", "Map.forEach()"), type, range, new ReplaceWithMapForEachFix()); } }