PsiElementVisitor (@NotNull ProblemsHolder holder, boolean isOnTheFly) { if (!PsiUtil.isLanguageLevel8OrHigher(holder.getFile())) { return PsiElementVisitor.EMPTY_VISITOR; } return new JavaElementVisitor() { @Override public void visitMethodCallExpression(@NotNull PsiMethodCallExpression methodCall) { if (STREAM_COUNT.test(methodCall)) { PsiMethodCallExpression qualifierCall = getQualifierMethodCall(methodCall); CountFix fix = FIX_MAPPER.mapFirst(qualifierCall); if (fix == null && !(STREAM_LIMIT.test(qualifierCall) && ExpressionUtils.isOne(qualifierCall.getArgumentList().getExpressions()[0]))) { if (extractComparison(methodCall, true) != null) { fix = new CountFix(SimplificationMode.IS_PRESENT); } else if (extractComparison(methodCall, false) != null) { final SimplificationMode simplificationMode; if (PsiUtil.getLanguageLevel(methodCall).isAtLeast(LanguageLevel.JDK_11)) { simplificationMode = SimplificationMode.IS_EMPTY; } else { simplificationMode = SimplificationMode.NOT_IS_PRESENT; } fix = new CountFix(simplificationMode); } } if (fix != null) { PsiElement nameElement = methodCall.getMethodExpression().getReferenceNameElement(); LOG.assertTrue(nameElement != null); holder.registerProblem(methodCall, nameElement.getTextRange().shiftRight(-methodCall.getTextOffset()), fix.getMessage(), fix); } } } }; }