PsiElementVisitor (@NotNull ProblemsHolder holder, boolean isOnTheFly) { LanguageLevel level = PsiUtil.getLanguageLevel(holder.getFile()); if (level.isLessThan(LanguageLevel.JDK_1_8)) { return PsiElementVisitor.EMPTY_VISITOR; } return new OptionalChainVisitor(level) { @Override protected void handleSimplification(@NotNull PsiMethodCallExpression call, @NotNull OptionalSimplificationFix fix) { PsiElement element = call.getMethodExpression().getReferenceNameElement(); holder.registerProblem(element != null ? element : call, fix.getDescription(), fix); } }; }