PsiElementVisitor (@NotNull ProblemsHolder holder, boolean isOnTheFly) { if (!PsiUtil.isLanguageLevel8OrHigher(holder.getFile())) { return PsiElementVisitor.EMPTY_VISITOR; } return new JavaElementVisitor() { @Override public void visitPolyadicExpression(@NotNull PsiPolyadicExpression expression) { TerminalGenerator generator = getGenerator(expression); if (generator == null) return; List<PsiExpression> diff = extractDiff(generator, expression); if (diff.isEmpty()) return; if (!LambdaGenerationUtil.canBeUncheckedLambda(expression)) return; boolean stringJoin = generator.isStringJoin(expression, diff); String message = JavaBundle.message(stringJoin ? "inspection.fold.expression.into.string.display.name" : "inspection.fold.expression.into.stream.display.name"); holder.registerProblem(expression, message, new FoldExpressionIntoStreamFix(stringJoin)); } }; }