Search in sources :

Example 1 with InspectionToolWrapper

use of com.intellij.codeInspection.ex.InspectionToolWrapper in project intellij-community by JetBrains.

the class PyCompatibilityInspectionAdvertiser method isCompatibilityInspectionEnabled.

private static boolean isCompatibilityInspectionEnabled(@NotNull PsiElement anchor) {
    final InspectionProfile profile = InspectionProfileManager.getInstance(anchor.getProject()).getCurrentProfile();
    final InspectionToolWrapper tool = profile.getInspectionTool(getCompatibilityInspectionShortName(), anchor.getProject());
    return tool != null && profile.isToolEnabled(HighlightDisplayKey.findById(tool.getID()), anchor);
}
Also used : InspectionProfile(com.intellij.codeInspection.InspectionProfile) InspectionToolWrapper(com.intellij.codeInspection.ex.InspectionToolWrapper)

Example 2 with InspectionToolWrapper

use of com.intellij.codeInspection.ex.InspectionToolWrapper in project intellij-community by JetBrains.

the class PyCompatibilityInspectionAdvertiser method enableCompatibilityInspection.

private static void enableCompatibilityInspection(@NotNull Project project) {
    final InspectionProfileImpl profile = InspectionProfileManager.getInstance(project).getCurrentProfile();
    final InspectionToolWrapper tool = profile.getInspectionTool(getCompatibilityInspectionShortName(), project);
    if (tool != null) {
        profile.setToolEnabled(tool.getShortName(), true);
        EditInspectionToolsSettingsAction.editToolSettings(project, profile, getCompatibilityInspectionShortName());
    }
}
Also used : InspectionProfileImpl(com.intellij.codeInspection.ex.InspectionProfileImpl) InspectionToolWrapper(com.intellij.codeInspection.ex.InspectionToolWrapper)

Example 3 with InspectionToolWrapper

use of com.intellij.codeInspection.ex.InspectionToolWrapper in project intellij-community by JetBrains.

the class InspectionTestUtil method compareToolResults.

static void compareToolResults(@NotNull GlobalInspectionContextImpl context, boolean checkRange, @NotNull String testDir, @NotNull Collection<? extends InspectionToolWrapper> toolWrappers) {
    final Element root = new Element("problems");
    for (InspectionToolWrapper toolWrapper : toolWrappers) {
        InspectionToolPresentation presentation = context.getPresentation(toolWrapper);
        //e.g. dead code need check for reachables
        presentation.updateContent();
        presentation.exportResults(root, x -> false, x -> false);
    }
    try {
        File file = new File(testDir + "/expected.xml");
        compareWithExpected(JDOMUtil.loadDocument(file), new Document(root), checkRange);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : InspectionToolPresentation(com.intellij.codeInspection.ui.InspectionToolPresentation) Element(org.jdom.Element) Document(org.jdom.Document) InspectionToolWrapper(com.intellij.codeInspection.ex.InspectionToolWrapper) File(java.io.File)

Example 4 with InspectionToolWrapper

use of com.intellij.codeInspection.ex.InspectionToolWrapper in project intellij-community by JetBrains.

the class SuppressForTestsScopeFix method addRemoveTestsScope.

private void addRemoveTestsScope(Project project, boolean add) {
    final InspectionProfileImpl profile = InspectionProjectProfileManager.getInstance(project).getCurrentProfile();
    final String shortName = myInspection.getShortName();
    final InspectionToolWrapper tool = profile.getInspectionTool(shortName, project);
    if (tool == null) {
        return;
    }
    if (add) {
        final NamedScope namedScope = NamedScopesHolder.getScope(project, "Tests");
        final HighlightDisplayKey key = HighlightDisplayKey.find(shortName);
        final HighlightDisplayLevel level = profile.getErrorLevel(key, namedScope, project);
        profile.addScope(tool, namedScope, level, false, project);
    } else {
        profile.removeScope(shortName, "Tests", project);
    }
    profile.scopesChanged();
}
Also used : InspectionProfileImpl(com.intellij.codeInspection.ex.InspectionProfileImpl) NamedScope(com.intellij.psi.search.scope.packageSet.NamedScope) HighlightDisplayLevel(com.intellij.codeHighlighting.HighlightDisplayLevel) HighlightDisplayKey(com.intellij.codeInsight.daemon.HighlightDisplayKey) InspectionToolWrapper(com.intellij.codeInspection.ex.InspectionToolWrapper)

Example 5 with InspectionToolWrapper

use of com.intellij.codeInspection.ex.InspectionToolWrapper in project intellij-community by JetBrains.

the class RedundantSuppressTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    myInspectionToolWrappers = new InspectionToolWrapper[] { new LocalInspectionToolWrapper(new JavaDocReferenceInspection()), new LocalInspectionToolWrapper(new I18nInspection()), new LocalInspectionToolWrapper(new RawUseOfParameterizedTypeInspection()), new GlobalInspectionToolWrapper(new EmptyMethodInspection()), new GlobalInspectionToolWrapper(new UnusedDeclarationInspection()) };
    myWrapper = new GlobalInspectionToolWrapper(new RedundantSuppressInspection() {

        @NotNull
        @Override
        protected InspectionToolWrapper[] getInspectionTools(PsiElement psiElement, @NotNull InspectionManager manager) {
            return myInspectionToolWrappers;
        }
    });
}
Also used : JavaDocReferenceInspection(com.intellij.codeInspection.javaDoc.JavaDocReferenceInspection) GlobalInspectionToolWrapper(com.intellij.codeInspection.ex.GlobalInspectionToolWrapper) I18nInspection(com.intellij.codeInspection.i18n.I18nInspection) RawUseOfParameterizedTypeInspection(com.siyeh.ig.migration.RawUseOfParameterizedTypeInspection) EmptyMethodInspection(com.intellij.codeInspection.emptyMethod.EmptyMethodInspection) LocalInspectionToolWrapper(com.intellij.codeInspection.ex.LocalInspectionToolWrapper) UnusedDeclarationInspection(com.intellij.codeInspection.deadCode.UnusedDeclarationInspection) NotNull(org.jetbrains.annotations.NotNull) GlobalInspectionToolWrapper(com.intellij.codeInspection.ex.GlobalInspectionToolWrapper) InspectionToolWrapper(com.intellij.codeInspection.ex.InspectionToolWrapper) LocalInspectionToolWrapper(com.intellij.codeInspection.ex.LocalInspectionToolWrapper) PsiElement(com.intellij.psi.PsiElement)

Aggregations

InspectionToolWrapper (com.intellij.codeInspection.ex.InspectionToolWrapper)34 NotNull (org.jetbrains.annotations.NotNull)10 InspectionProfile (com.intellij.codeInspection.InspectionProfile)7 LocalInspectionToolWrapper (com.intellij.codeInspection.ex.LocalInspectionToolWrapper)6 File (java.io.File)6 Project (com.intellij.openapi.project.Project)5 InspectionProfileImpl (com.intellij.codeInspection.ex.InspectionProfileImpl)4 HighlightDisplayKey (com.intellij.codeInsight.daemon.HighlightDisplayKey)3 TextRange (com.intellij.openapi.util.TextRange)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 PsiFile (com.intellij.psi.PsiFile)3 Element (org.jdom.Element)3 AnalysisScope (com.intellij.analysis.AnalysisScope)2 HighlightDisplayLevel (com.intellij.codeHighlighting.HighlightDisplayLevel)2 IntentionAction (com.intellij.codeInsight.intention.IntentionAction)2 IntentionManager (com.intellij.codeInsight.intention.IntentionManager)2 IntentionHintComponent (com.intellij.codeInsight.intention.impl.IntentionHintComponent)2 GlobalInspectionToolWrapper (com.intellij.codeInspection.ex.GlobalInspectionToolWrapper)2 InspectionManagerEx (com.intellij.codeInspection.ex.InspectionManagerEx)2 InspectionResultsView (com.intellij.codeInspection.ui.InspectionResultsView)2