PsiElementVisitor (@NotNull final ProblemsHolder holder, boolean isOnTheFly) { return new JavaElementVisitor() { @Override public void visitMethodCallExpression(@NotNull PsiMethodCallExpression call) { if (TestUtils.isInTestCode(call)) return; super.visitMethodCallExpression(call); if (!LIST_CONTAINS_ALL.test(call)) return; PsiReferenceExpression expression = call.getMethodExpression(); final PsiExpression qualifier = ExpressionUtils.getEffectiveQualifier(expression); if (qualifier == null) return; final LongRangeSet listSizeRange = SlowAbstractSetRemoveAllInspection.getSizeRangeOfCollection(qualifier); if (listSizeRange.isEmpty() || listSizeRange.max() <= 5) return; holder.registerProblem(call, JavaBundle.message("inspection.slow.list.contains.all.description"), ProblemHighlightType.WARNING, expression.getTextRangeInParent(), new ReplaceWithHashSetContainsAllFix(qualifier.getText())); } }; }