PsiElementVisitor (@NotNull final ProblemsHolder holder, boolean isOnTheFly) { if (!JavaFeature.ADVANCED_COLLECTIONS_API.isFeatureSupported(holder.getFile())) { return PsiElementVisitor.EMPTY_VISITOR; } return new JavaElementVisitor() { @Override public void visitMethodCallExpression(@NotNull PsiMethodCallExpression expression) { super.visitMethodCallExpression(expression); PsiElement nameElement = expression.getMethodExpression().getReferenceNameElement(); if(nameElement != null && expression.getArgumentList().getExpressionCount() == 2 && "sort".equals(nameElement.getText())) { PsiMethod method = expression.resolveMethod(); if(method != null) { PsiClass containingClass = method.getContainingClass(); if(containingClass != null && CommonClassNames.JAVA_UTIL_COLLECTIONS.equals(containingClass.getQualifiedName())) { holder.registerProblem(nameElement, QuickFixBundle.message("java.8.list.sort.inspection.description"), new ReplaceWithListSortFix()); } } } } }; }