Search in sources :

Example 16 with InspectionToolWrapper

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

the class RunInspectionAction method copyToolWithSettings.

private static InspectionToolWrapper copyToolWithSettings(@NotNull final InspectionToolWrapper tool) {
    final Element options = new Element("copy");
    tool.getTool().writeSettings(options);
    final InspectionToolWrapper copiedTool = tool.createCopy();
    try {
        copiedTool.getTool().readSettings(options);
    } catch (InvalidDataException e) {
        throw new RuntimeException(e);
    }
    return copiedTool;
}
Also used : Element(org.jdom.Element) InvalidDataException(com.intellij.openapi.util.InvalidDataException) InspectionToolWrapper(com.intellij.codeInspection.ex.InspectionToolWrapper)

Example 17 with InspectionToolWrapper

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

the class HighlightStressTest method configureLocalInspectionTools.

@NotNull
@Override
protected LocalInspectionTool[] configureLocalInspectionTools() {
    if ("RandomEditingForUnused".equals(getTestName(false))) {
        return new LocalInspectionTool[] { new UnusedImportLocalInspection() };
    }
    List<InspectionToolWrapper> all = InspectionToolRegistrar.getInstance().createTools();
    List<LocalInspectionTool> locals = new ArrayList<>();
    for (InspectionToolWrapper tool : all) {
        if (tool instanceof LocalInspectionToolWrapper) {
            LocalInspectionTool e = ((LocalInspectionToolWrapper) tool).getTool();
            locals.add(e);
        }
    }
    return locals.toArray(new LocalInspectionTool[locals.size()]);
}
Also used : UnusedImportLocalInspection(com.intellij.codeInspection.unusedImport.UnusedImportLocalInspection) LocalInspectionTool(com.intellij.codeInspection.LocalInspectionTool) LocalInspectionToolWrapper(com.intellij.codeInspection.ex.LocalInspectionToolWrapper) InspectionToolWrapper(com.intellij.codeInspection.ex.InspectionToolWrapper) LocalInspectionToolWrapper(com.intellij.codeInspection.ex.LocalInspectionToolWrapper) NotNull(org.jetbrains.annotations.NotNull)

Example 18 with InspectionToolWrapper

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

the class EntryPointsNode method createDummyWrapper.

private static InspectionToolWrapper createDummyWrapper(@NotNull GlobalInspectionContextImpl context) {
    InspectionToolWrapper toolWrapper = new GlobalInspectionToolWrapper(new DummyEntryPointsEP());
    toolWrapper.initialize(context);
    return toolWrapper;
}
Also used : GlobalInspectionToolWrapper(com.intellij.codeInspection.ex.GlobalInspectionToolWrapper) GlobalInspectionToolWrapper(com.intellij.codeInspection.ex.GlobalInspectionToolWrapper) InspectionToolWrapper(com.intellij.codeInspection.ex.InspectionToolWrapper) DummyEntryPointsEP(com.intellij.codeInspection.deadCode.DummyEntryPointsEP)

Example 19 with InspectionToolWrapper

use of com.intellij.codeInspection.ex.InspectionToolWrapper in project go-lang-idea-plugin by go-lang-plugin-org.

the class GoPerformanceTest method doInspectionTest.

private void doInspectionTest(@NotNull InspectionProfileEntry tool, long expected) {
    VirtualFile sourceDir = installTestData("docker");
    if (sourceDir == null)
        return;
    // noinspection ConstantConditions
    AnalysisScope scope = new AnalysisScope(getPsiManager().findDirectory(sourceDir));
    scope.invalidate();
    InspectionManagerEx inspectionManager = (InspectionManagerEx) InspectionManager.getInstance(getProject());
    InspectionToolWrapper wrapper = InspectionToolRegistrar.wrapTool(tool);
    GlobalInspectionContextForTests globalContext = CodeInsightTestFixtureImpl.createGlobalContextForTool(scope, getProject(), inspectionManager, wrapper);
    PlatformTestUtil.startPerformanceTest(getTestName(true), (int) expected, () -> InspectionTestUtil.runTool(wrapper, scope, globalContext)).cpuBound().usesAllCPUCores().assertTiming();
    InspectionTestUtil.compareToolResults(globalContext, wrapper, false, new File(getTestDataPath(), wrapper.getShortName()).getPath());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) AnalysisScope(com.intellij.analysis.AnalysisScope) InspectionManagerEx(com.intellij.codeInspection.ex.InspectionManagerEx) GlobalInspectionContextForTests(com.intellij.testFramework.fixtures.impl.GlobalInspectionContextForTests) InspectionToolWrapper(com.intellij.codeInspection.ex.InspectionToolWrapper) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Example 20 with InspectionToolWrapper

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

the class AndroidLintInspectionBase method getInspectionShortNameByIssue.

public static String getInspectionShortNameByIssue(@NotNull Project project, @NotNull Issue issue) {
    synchronized (ISSUE_MAP_LOCK) {
        if (ourIssue2InspectionShortName == null) {
            ourIssue2InspectionShortName = new HashMap<>();
            final InspectionProfile profile = InspectionProjectProfileManager.getInstance(project).getCurrentProfile();
            for (InspectionToolWrapper e : profile.getInspectionTools(null)) {
                final String shortName = e.getShortName();
                if (shortName.startsWith(LINT_INSPECTION_PREFIX)) {
                    final InspectionProfileEntry entry = e.getTool();
                    if (entry instanceof AndroidLintInspectionBase) {
                        final Issue s = ((AndroidLintInspectionBase) entry).getIssue();
                        ourIssue2InspectionShortName.put(s, shortName);
                    }
                }
            }
        }
        return ourIssue2InspectionShortName.get(issue);
    }
}
Also used : InspectionToolWrapper(com.intellij.codeInspection.ex.InspectionToolWrapper)

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