@@ -0,0 +1,2213 @@
+// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.%0Apackage com.intellij.lang.jvm.inspection;%0A%0Aimport com.intellij.codeInspection.LocalInspectionTool;%0Aimport com.intellij.codeInspection.ProblemHighlightType;%0Aimport com.intellij.codeInspection.ProblemsHolder;%0Aimport com.intellij.lang.jvm.JvmElement;%0Aimport com.intellij.lang.jvm.JvmElementVisitor;%0Aimport com.intellij.lang.jvm.source.JvmDeclarationSearch;%0Aimport com.intellij.openapi.project.Project;%0Aimport com.intellij.psi.PsiElement;%0Aimport com.intellij.psi.PsiElementVisitor;%0Aimport org.jetbrains.annotations.Nls;%0Aimport org.jetbrains.annotations.NotNull;%0Aimport org.jetbrains.annotations.Nullable;%0A%0Apublic abstract class JvmLocalInspection extends LocalInspectionTool %7B%0A%0A  @NotNull%0A  @Override%0A  public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) %7B%0A    return new PsiElementVisitor() %7B%0A      @Override%0A      public void visitElement(PsiElement element) %7B%0A        JvmElementVisitor%3CBoolean%3E visitor = null;%0A        for (JvmElement jvmElement : JvmDeclarationSearch.getElementsByIdentifier(element)) %7B%0A          if (visitor == null) %7B%0A            // don't build visitor until there is at least one JvmElement%0A            visitor = buildJvmVisitor(%0A              holder.getProject(),%0A              (message, highlightType) -%3E holder.registerProblem(element, message, highlightType)%0A            );%0A            if (visitor == null) return;%0A          %7D%0A          Boolean result = jvmElement.accept(visitor);%0A          if (result == Boolean.TRUE) %7B%0A            return;%0A          %7D%0A        %7D%0A      %7D%0A    %7D;%0A  %7D%0A%0A  protected interface HighlightSink %7B%0A%0A    default void highlight(@Nls(capitalization = Nls.Capitalization.Sentence) @NotNull String message) %7B%0A      highlight(message, ProblemHighlightType.GENERIC_ERROR_OR_WARNING);%0A    %7D%0A%0A    void highlight(@Nls(capitalization = Nls.Capitalization.Sentence) @NotNull String message,%0A                   @NotNull ProblemHighlightType highlightType);%0A  %7D%0A%0A  @Nullable%0A  protected abstract JvmElementVisitor%3CBoolean%3E buildJvmVisitor(@NotNull Project project, @NotNull HighlightSink message);%0A%7D%0A

add JvmElement-based local inspection