Search in sources :

Example 21 with InspectionProfileImpl

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

the class InspectionProfileLoadUtil method load.

@NotNull
public static InspectionProfileImpl load(@NotNull Path file, @NotNull InspectionToolRegistrar registrar, @NotNull InspectionProfileManager profileManager) throws JDOMException, IOException, InvalidDataException {
    Element element = JdomKt.loadElement(file);
    InspectionProfileImpl profile = new InspectionProfileImpl(getProfileName(file, element), registrar, (BaseInspectionProfileManager) profileManager);
    final Element profileElement = element.getChild("profile");
    if (profileElement != null) {
        element = profileElement;
    }
    profile.readExternal(element);
    return profile;
}
Also used : InspectionProfileImpl(com.intellij.codeInspection.ex.InspectionProfileImpl) Element(org.jdom.Element) NotNull(org.jetbrains.annotations.NotNull)

Example 22 with InspectionProfileImpl

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

the class ExternalToolPass method collectInformationWithProgress.

@Override
protected void collectInformationWithProgress(@NotNull ProgressIndicator progress) {
    final FileViewProvider viewProvider = myFile.getViewProvider();
    final Set<Language> relevantLanguages = viewProvider.getLanguages();
    int externalAnnotatorsInRoots = 0;
    for (Language language : relevantLanguages) {
        PsiFile psiRoot = viewProvider.getPsi(language);
        if (!HighlightingLevelManager.getInstance(myProject).shouldInspect(psiRoot))
            continue;
        final List<ExternalAnnotator> externalAnnotators = ExternalLanguageAnnotators.allForFile(language, psiRoot);
        externalAnnotatorsInRoots += externalAnnotators.size();
    }
    setProgressLimit(externalAnnotatorsInRoots);
    InspectionProfileImpl profile = InspectionProjectProfileManager.getInstance(myProject).getCurrentProfile();
    for (Language language : relevantLanguages) {
        PsiFile psiRoot = viewProvider.getPsi(language);
        if (!HighlightingLevelManager.getInstance(myProject).shouldInspect(psiRoot))
            continue;
        final List<ExternalAnnotator> externalAnnotators = ExternalLanguageAnnotators.allForFile(language, psiRoot);
        if (!externalAnnotators.isEmpty()) {
            DaemonCodeAnalyzerEx daemonCodeAnalyzer = DaemonCodeAnalyzerEx.getInstanceEx(myProject);
            boolean errorFound = daemonCodeAnalyzer.getFileStatusMap().wasErrorFound(myDocument);
            for (ExternalAnnotator externalAnnotator : externalAnnotators) {
                String shortName = externalAnnotator.getPairedBatchInspectionShortName();
                if (shortName != null) {
                    HighlightDisplayKey key = HighlightDisplayKey.find(shortName);
                    LOG.assertTrue(key != null, "Paired tool '" + shortName + "' not found for external annotator: " + externalAnnotator);
                    if (!profile.isToolEnabled(key, myFile))
                        continue;
                }
                final Object collectedInfo;
                Editor editor = getEditor();
                if (editor != null) {
                    collectedInfo = externalAnnotator.collectInformation(psiRoot, editor, errorFound);
                } else {
                    collectedInfo = externalAnnotator.collectInformation(psiRoot);
                }
                advanceProgress(1);
                if (collectedInfo != null) {
                    myAnnotator2DataMap.put(externalAnnotator, new MyData(psiRoot, collectedInfo));
                }
            }
        }
    }
}
Also used : ExternalAnnotator(com.intellij.lang.annotation.ExternalAnnotator) InspectionProfileImpl(com.intellij.codeInspection.ex.InspectionProfileImpl) HighlightDisplayKey(com.intellij.codeInsight.daemon.HighlightDisplayKey) FileViewProvider(com.intellij.psi.FileViewProvider) Language(com.intellij.lang.Language) PsiFile(com.intellij.psi.PsiFile) Editor(com.intellij.openapi.editor.Editor)

Example 23 with InspectionProfileImpl

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

the class PyCompatibilityInspectionAdvertiser method enableVersions.

private static void enableVersions(@NotNull Project project, @NotNull PsiElement file, @NotNull List<LanguageLevel> versions) {
    final InspectionProfileImpl profile = InspectionProjectProfileManager.getInstance(project).getCurrentProfile();
    final String shortName = getCompatibilityInspectionShortName();
    final InspectionToolWrapper tool = profile.getInspectionTool(shortName, project);
    if (tool != null) {
        profile.modifyProfile(model -> {
            final PyCompatibilityInspection inspection = (PyCompatibilityInspection) model.getUnwrappedTool(shortName, file);
            inspection.ourVersions.addAll(ContainerUtil.map(versions, LanguageLevel::toString));
        });
        EditInspectionToolsSettingsAction.editToolSettings(project, profile, shortName);
    }
}
Also used : InspectionProfileImpl(com.intellij.codeInspection.ex.InspectionProfileImpl) InspectionToolWrapper(com.intellij.codeInspection.ex.InspectionToolWrapper)

Example 24 with InspectionProfileImpl

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

the class HtmlMissingClosingTagInspectionTest method highlightTest.

protected void highlightTest(@Language("HTML") String code) {
    final LocalInspectionTool inspection = getInspection();
    myFixture.enableInspections(inspection);
    final HighlightDisplayKey displayKey = HighlightDisplayKey.find(inspection.getShortName());
    final Project project = myFixture.getProject();
    final InspectionProfileImpl currentProfile = ProjectInspectionProfileManager.getInstance(project).getCurrentProfile();
    final HighlightDisplayLevel errorLevel = currentProfile.getErrorLevel(displayKey, null);
    if (errorLevel == HighlightDisplayLevel.DO_NOT_SHOW) {
        currentProfile.setErrorLevel(displayKey, HighlightDisplayLevel.WARNING, project);
    }
    myFixture.configureByText(HtmlFileType.INSTANCE, code);
    myFixture.testHighlighting();
}
Also used : Project(com.intellij.openapi.project.Project) InspectionProfileImpl(com.intellij.codeInspection.ex.InspectionProfileImpl) HighlightDisplayLevel(com.intellij.codeHighlighting.HighlightDisplayLevel) HighlightDisplayKey(com.intellij.codeInsight.daemon.HighlightDisplayKey) LocalInspectionTool(com.intellij.codeInspection.LocalInspectionTool)

Aggregations

InspectionProfileImpl (com.intellij.codeInspection.ex.InspectionProfileImpl)24 HighlightDisplayKey (com.intellij.codeInsight.daemon.HighlightDisplayKey)7 HighlightDisplayLevel (com.intellij.codeHighlighting.HighlightDisplayLevel)5 InspectionToolWrapper (com.intellij.codeInspection.ex.InspectionToolWrapper)5 Project (com.intellij.openapi.project.Project)5 NotNull (org.jetbrains.annotations.NotNull)5 SingleInspectionProfilePanel (com.intellij.profile.codeInspection.ui.SingleInspectionProfilePanel)3 ActionEvent (java.awt.event.ActionEvent)3 InspectionProfile (com.intellij.codeInspection.InspectionProfile)2 LocalInspectionTool (com.intellij.codeInspection.LocalInspectionTool)2 InspectionManagerEx (com.intellij.codeInspection.ex.InspectionManagerEx)2 InspectionProfileModifiableModel (com.intellij.codeInspection.ex.InspectionProfileModifiableModel)2 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)2 PsiFile (com.intellij.psi.PsiFile)2 Element (org.jdom.Element)2 AnalysisScope (com.intellij.analysis.AnalysisScope)1 AnalysisUIOptions (com.intellij.analysis.AnalysisUIOptions)1 BaseAnalysisActionDialog (com.intellij.analysis.BaseAnalysisActionDialog)1 DescriptionAwareSchemeActions (com.intellij.application.options.schemes.DescriptionAwareSchemeActions)1 SchemesCombo (com.intellij.application.options.schemes.SchemesCombo)1