PsiElementVisitor (@NotNull ProblemsHolder holder, boolean isOnTheFly) { if (!PsiUtil.isLanguageLevel9OrHigher(holder.getFile())) { return PsiElementVisitor.EMPTY_VISITOR; } return new JavaElementVisitor() { @Override public void visitMethodCallExpression(@NotNull PsiMethodCallExpression call) { PrepopulatedCollectionModel model = MAPPER.mapFirst(call); if (model != null && model.isValid(SUGGEST_MAP_OF_ENTRIES)) { ProblemHighlightType type = model.myConstantContent || !IGNORE_NON_CONSTANT ? ProblemHighlightType.GENERIC_ERROR_OR_WARNING : ProblemHighlightType.INFORMATION; if (type == ProblemHighlightType.INFORMATION && !isOnTheFly) return; boolean wholeStatement = isOnTheFly && (type == ProblemHighlightType.INFORMATION || InspectionProjectProfileManager.isInformationLevel(getShortName(), call)); PsiElement element = wholeStatement ? call : call.getMethodExpression().getReferenceNameElement(); if(element != null) { String replacementMethod = model.hasTooManyMapEntries() ? "ofEntries" : model.myCopy ? "copyOf" : "of"; String fixMessage = JavaBundle.message("inspection.collection.factories.fix.name", model.myType, replacementMethod); String inspectionMessage = JavaBundle.message("inspection.collection.factories.message", model.myType, replacementMethod); holder.registerProblem(element, inspectionMessage, type, new ReplaceWithCollectionFactoryFix(fixMessage)); } } } }; }