PsiElementVisitor (@NotNull ProblemsHolder holder, boolean isOnTheFly) { if (!PsiUtil.isLanguageLevel8OrHigher(holder.getFile())) { return PsiElementVisitor.EMPTY_VISITOR; } return new JavaElementVisitor() { @Override public void visitMethodCallExpression(@NotNull PsiMethodCallExpression call) { if (STREAM_COLLECT.test(call)) { PsiMethodCallExpression arg = tryCast(PsiUtil.skipParenthesizedExprDown(call.getArgumentList().getExpressions()[0]), PsiMethodCallExpression.class); if (COLLECT_TO_COLLECTION.test(arg)) { CollectTerminal newTerminal = extractTerminal(call); if (newTerminal == null) return; PsiElement nameElement = call.getMethodExpression().getReferenceNameElement(); if (nameElement == null) return; String fusedSteps = newTerminal.fusedElements().collect(NlsMessages.joiningAnd()); holder.registerProblem(nameElement, JavaBundle.message("inspection.fuse.stream.operations.message", fusedSteps), new FuseStreamOperationsFix(fusedSteps, myStrictMode)); } } } }; }