PsiElementVisitor (@NotNull final ProblemsHolder holder, boolean isOnTheFly) { if (!JavaFeature.STREAMS.isFeatureSupported(holder.getFile())) { return PsiElementVisitor.EMPTY_VISITOR; } return new JavaElementVisitor() { @Override public void visitMethodCallExpression(@NotNull PsiMethodCallExpression methodCallExpression) { String qName = methodCallExpression.getMethodExpression().getQualifiedName(); if (qName == null) { return; } qName = StringUtil.getShortName(qName); final Collection<StaticPseudoFunctionalStyleMethodOptions.PipelineElement> handlerInfos = myOptions.findElementsByMethodName(qName); if (handlerInfos.isEmpty()) { return; } final PsiMethod method = methodCallExpression.resolveMethod(); if (method == null) { return; } final PsiClass aClass = method.getContainingClass(); if (aClass == null) { return; } final String classQualifiedName = aClass.getQualifiedName(); if (classQualifiedName == null) { return; } StaticPseudoFunctionalStyleMethodOptions.PipelineElement suitableHandler = null; for (StaticPseudoFunctionalStyleMethodOptions.PipelineElement h : handlerInfos) { if (h.handlerClass().equals(classQualifiedName)) { suitableHandler = h; break; } } if (suitableHandler == null) { return; } final PseudoLambdaReplaceTemplate.ValidationInfo validationInfo = suitableHandler.template().validate(methodCallExpression); if (validationInfo != null) { holder.registerProblem(methodCallExpression.getMethodExpression(), JavaBundle.message("inspection.message.pseudo.functional.style.code"), new ReplacePseudoLambdaWithLambda(suitableHandler)); } } }; }