PsiElementVisitor (@NotNull final ProblemsHolder holder, boolean isOnTheFly) { if (!HighlightingFeature.LAMBDA_EXPRESSIONS.isAvailable(holder.getFile())) { return PsiElementVisitor.EMPTY_VISITOR; } return new JavaElementVisitor() { @Override public void visitLambdaExpression(@NotNull PsiLambdaExpression expression) { super.visitLambdaExpression(expression); final PsiElement body = expression.getBody(); MethodReferenceCandidate methodRefCandidate = extractMethodReferenceCandidateExpression(body); if (methodRefCandidate == null) return; final PsiExpression candidate = getLambdaToMethodReferenceConversionCandidate(expression, methodRefCandidate.myExpression); if (candidate == null) return; ProblemHighlightType type; if (methodRefCandidate.mySafeQualifier && methodRefCandidate.myConformsCodeStyle) { type = ProblemHighlightType.GENERIC_ERROR_OR_WARNING; } else { if (!isOnTheFly) return; type = ProblemHighlightType.INFORMATION; } PsiElement element = type == ProblemHighlightType.INFORMATION || InspectionProjectProfileManager.isInformationLevel(getShortName(), expression) ? expression : candidate; holder.registerProblem(holder.getManager().createProblemDescriptor( element, getDisplayName(), type != ProblemHighlightType.INFORMATION, type, true, new ReplaceWithMethodRefFix(methodRefCandidate.mySafeQualifier))); } }; }