Search in sources :

Example 6 with SeverityRegistrar

use of com.intellij.codeInsight.daemon.impl.SeverityRegistrar in project intellij-community by JetBrains.

the class ToolsImpl method readExternal.

void readExternal(@NotNull Element toolElement, @NotNull InspectionProfileManager profileManager, Map<String, List<String>> dependencies) {
    final String levelName = toolElement.getAttributeValue(LEVEL_ATTRIBUTE);
    final SeverityRegistrar registrar = profileManager.getOwnSeverityRegistrar();
    HighlightDisplayLevel level = levelName != null ? HighlightDisplayLevel.find(registrar.getSeverity(levelName)) : null;
    if (level == null) {
        level = HighlightDisplayLevel.WARNING;
    }
    myDefaultState.setLevel(level);
    final String enabled = toolElement.getAttributeValue(ENABLED_ATTRIBUTE);
    final boolean isEnabled = enabled != null && Boolean.parseBoolean(enabled);
    final String enabledTool = toolElement.getAttributeValue(ENABLED_BY_DEFAULT_ATTRIBUTE);
    myDefaultState.setEnabled(enabledTool != null ? Boolean.parseBoolean(enabledTool) : isEnabled);
    final InspectionToolWrapper toolWrapper = myDefaultState.getTool();
    final List<Element> scopeElements = toolElement.getChildren(ProfileEx.SCOPE);
    if (!scopeElements.isEmpty()) {
        final List<String> scopeNames = new SmartList<>();
        for (Element scopeElement : scopeElements) {
            final String scopeName = scopeElement.getAttributeValue(ProfileEx.NAME);
            if (scopeName == null) {
                continue;
            }
            final NamedScopesHolder scopesHolder = profileManager.getScopesManager();
            NamedScope namedScope = null;
            if (scopesHolder != null) {
                namedScope = scopesHolder.getScope(scopeName);
            }
            final String errorLevel = scopeElement.getAttributeValue(LEVEL_ATTRIBUTE);
            final String enabledInScope = scopeElement.getAttributeValue(ENABLED_ATTRIBUTE);
            final InspectionToolWrapper copyToolWrapper = toolWrapper.createCopy();
            // check if unknown children exists
            if (scopeElement.getAttributes().size() > 3 || !scopeElement.getChildren().isEmpty()) {
                copyToolWrapper.getTool().readSettings(scopeElement);
            }
            HighlightDisplayLevel scopeLevel = errorLevel != null ? HighlightDisplayLevel.find(registrar.getSeverity(errorLevel)) : null;
            if (scopeLevel == null) {
                scopeLevel = level;
            }
            if (namedScope != null) {
                addTool(namedScope, copyToolWrapper, enabledInScope != null && Boolean.parseBoolean(enabledInScope), scopeLevel);
            } else {
                addTool(scopeName, copyToolWrapper, enabledInScope != null && Boolean.parseBoolean(enabledInScope), scopeLevel);
            }
            scopeNames.add(scopeName);
        }
        for (int i = 0; i < scopeNames.size(); i++) {
            String scopeName = scopeNames.get(i);
            List<String> order = dependencies.get(scopeName);
            if (order == null) {
                order = new ArrayList<>();
                dependencies.put(scopeName, order);
            }
            for (int j = i + 1; j < scopeNames.size(); j++) {
                order.add(scopeNames.get(j));
            }
        }
    }
    // check if unknown children exists
    if (toolElement.getAttributes().size() > 4 || toolElement.getChildren().size() > scopeElements.size()) {
        toolWrapper.getTool().readSettings(toolElement);
    }
    myEnabled = isEnabled;
}
Also used : HighlightDisplayLevel(com.intellij.codeHighlighting.HighlightDisplayLevel) PsiElement(com.intellij.psi.PsiElement) Element(org.jdom.Element) SeverityRegistrar(com.intellij.codeInsight.daemon.impl.SeverityRegistrar) SmartList(com.intellij.util.SmartList)

Example 7 with SeverityRegistrar

use of com.intellij.codeInsight.daemon.impl.SeverityRegistrar in project intellij-community by JetBrains.

the class FontEditorPreview method installTrafficLights.

static void installTrafficLights(@NotNull EditorEx editor) {
    TrafficLightRenderer renderer = new TrafficLightRenderer(null, null, null) {

        @NotNull
        @Override
        protected DaemonCodeAnalyzerStatus getDaemonCodeAnalyzerStatus(@NotNull SeverityRegistrar severityRegistrar) {
            DaemonCodeAnalyzerStatus status = new DaemonCodeAnalyzerStatus();
            status.errorAnalyzingFinished = true;
            status.errorCount = new int[] { 1, 2 };
            return status;
        }
    };
    Disposer.register((Disposable) editor.getCaretModel(), renderer);
    ((EditorMarkupModel) editor.getMarkupModel()).setErrorStripeRenderer(renderer);
    ((EditorMarkupModel) editor.getMarkupModel()).setErrorStripeVisible(true);
}
Also used : TrafficLightRenderer(com.intellij.codeInsight.daemon.impl.TrafficLightRenderer) SeverityRegistrar(com.intellij.codeInsight.daemon.impl.SeverityRegistrar) NotNull(org.jetbrains.annotations.NotNull) EditorMarkupModel(com.intellij.openapi.editor.ex.EditorMarkupModel)

Aggregations

SeverityRegistrar (com.intellij.codeInsight.daemon.impl.SeverityRegistrar)7 HighlightDisplayLevel (com.intellij.codeHighlighting.HighlightDisplayLevel)3 HighlightSeverity (com.intellij.lang.annotation.HighlightSeverity)3 TextAttributes (com.intellij.openapi.editor.markup.TextAttributes)2 PsiElement (com.intellij.psi.PsiElement)2 HighlightDisplayKey (com.intellij.codeInsight.daemon.HighlightDisplayKey)1 HighlightInfoType (com.intellij.codeInsight.daemon.impl.HighlightInfoType)1 TrafficLightRenderer (com.intellij.codeInsight.daemon.impl.TrafficLightRenderer)1 ErrorInfo (com.intellij.designer.model.ErrorInfo)1 Annotation (com.intellij.lang.annotation.Annotation)1 Document (com.intellij.openapi.editor.Document)1 EditorColorsScheme (com.intellij.openapi.editor.colors.EditorColorsScheme)1 TextAttributesKey (com.intellij.openapi.editor.colors.TextAttributesKey)1 EditorMarkupModel (com.intellij.openapi.editor.ex.EditorMarkupModel)1 Project (com.intellij.openapi.project.Project)1 InspectionProjectProfileManager (com.intellij.profile.codeInspection.InspectionProjectProfileManager)1 SmartList (com.intellij.util.SmartList)1 BaseActionFix (com.scss.annotator.BaseActionFix)1 ScssLintSettingsPage (com.scss.settings.ScssLintSettingsPage)1 Lint (com.scss.utils.scssLint.Lint)1