Search in sources :

Example 1 with SeverityRegistrar

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

the class ComponentTree method getHighlightDisplayLevel.

@Nullable
private static HighlightDisplayLevel getHighlightDisplayLevel(Project project, RadComponent component) {
    HighlightDisplayLevel displayLevel = null;
    SeverityRegistrar severityRegistrar = SeverityRegistrar.getSeverityRegistrar(project);
    for (ErrorInfo errorInfo : RadComponent.getError(component)) {
        if (displayLevel == null || severityRegistrar.compare(errorInfo.getLevel().getSeverity(), displayLevel.getSeverity()) > 0) {
            displayLevel = errorInfo.getLevel();
        }
    }
    return displayLevel;
}
Also used : HighlightDisplayLevel(com.intellij.codeHighlighting.HighlightDisplayLevel) ErrorInfo(com.intellij.designer.model.ErrorInfo) SeverityRegistrar(com.intellij.codeInsight.daemon.impl.SeverityRegistrar) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with SeverityRegistrar

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

the class SeverityEditorDialogAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    final Project project = e.getProject();
    final SeverityRegistrar severityRegistrar = SeverityRegistrar.getSeverityRegistrar(project);
    final Component component = PlatformDataKeys.CONTEXT_COMPONENT.getData(e.getDataContext());
    if (component instanceof JComponent) {
        final SeverityEditorDialog dialog = new SeverityEditorDialog((JComponent) component, null, severityRegistrar, false);
        dialog.show();
    }
}
Also used : Project(com.intellij.openapi.project.Project) SeverityRegistrar(com.intellij.codeInsight.daemon.impl.SeverityRegistrar)

Example 3 with SeverityRegistrar

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

the class SingleInspectionProfilePanel method copyUsedSeveritiesIfUndefined.

private static void copyUsedSeveritiesIfUndefined(InspectionProfileImpl selectedProfile, BaseInspectionProfileManager profileManager) {
    final SeverityRegistrar registrar = profileManager.getSeverityRegistrar();
    final Set<HighlightSeverity> severities = selectedProfile.getUsedSeverities();
    for (Iterator<HighlightSeverity> iterator = severities.iterator(); iterator.hasNext(); ) {
        HighlightSeverity severity = iterator.next();
        if (registrar.isSeverityValid(severity.getName())) {
            iterator.remove();
        }
    }
    if (!severities.isEmpty()) {
        final SeverityRegistrar oppositeRegister = selectedProfile.getProfileManager().getSeverityRegistrar();
        for (HighlightSeverity severity : severities) {
            final TextAttributesKey attributesKey = TextAttributesKey.find(severity.getName());
            final TextAttributes textAttributes = oppositeRegister.getTextAttributesBySeverity(severity);
            if (textAttributes == null) {
                continue;
            }
            HighlightInfoType.HighlightInfoTypeImpl info = new HighlightInfoType.HighlightInfoTypeImpl(severity, attributesKey);
            registrar.registerSeverity(new SeverityRegistrar.SeverityBasedTextAttributes(textAttributes.clone(), info), textAttributes.getErrorStripeColor());
        }
    }
}
Also used : HighlightSeverity(com.intellij.lang.annotation.HighlightSeverity) TextAttributes(com.intellij.openapi.editor.markup.TextAttributes) TextAttributesKey(com.intellij.openapi.editor.colors.TextAttributesKey) SeverityRegistrar(com.intellij.codeInsight.daemon.impl.SeverityRegistrar) HighlightInfoType(com.intellij.codeInsight.daemon.impl.HighlightInfoType)

Example 4 with SeverityRegistrar

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

the class SingleInspectionProfilePanel method compoundPopup.

private JPopupMenu compoundPopup() {
    final DefaultActionGroup group = new DefaultActionGroup();
    final SeverityRegistrar severityRegistrar = myProfile.getProfileManager().getOwnSeverityRegistrar();
    for (HighlightSeverity severity : LevelChooserAction.getSeverities(severityRegistrar, includeDoNotShow())) {
        final HighlightDisplayLevel level = HighlightDisplayLevel.find(severity);
        group.add(new AnAction(renderSeverity(severity), renderSeverity(severity), level.getIcon()) {

            @Override
            public void actionPerformed(@NotNull AnActionEvent e) {
                setNewHighlightingLevel(level);
            }

            @Override
            public boolean isDumbAware() {
                return true;
            }
        });
    }
    group.add(Separator.getInstance());
    ActionPopupMenu menu = ActionManager.getInstance().createActionPopupMenu(ActionPlaces.UNKNOWN, group);
    return menu.getComponent();
}
Also used : HighlightSeverity(com.intellij.lang.annotation.HighlightSeverity) HighlightDisplayLevel(com.intellij.codeHighlighting.HighlightDisplayLevel) SeverityRegistrar(com.intellij.codeInsight.daemon.impl.SeverityRegistrar)

Example 5 with SeverityRegistrar

use of com.intellij.codeInsight.daemon.impl.SeverityRegistrar in project scss-lint-plugin by idok.

the class ScssLintAnnotationResult method apply.

@Override
public void apply(@NotNull PsiFile file, ScssLintAnnotationResult annotationResult, @NotNull AnnotationHolder holder) {
    if (annotationResult == null) {
        return;
    }
    InspectionProjectProfileManager inspectionProjectProfileManager = InspectionProjectProfileManager.getInstance(file.getProject());
    SeverityRegistrar severityRegistrar = inspectionProjectProfileManager.getSeverityRegistrar();
    HighlightDisplayKey inspectionKey = getHighlightDisplayKeyByClass();
    EditorColorsScheme colorsScheme = annotationResult.input.colorsScheme;
    Document document = PsiDocumentManager.getInstance(file.getProject()).getDocument(file);
    if (document == null) {
        return;
    }
    if (annotationResult.fileLevel != null) {
        Annotation annotation = holder.createWarningAnnotation(file, annotationResult.fileLevel);
        annotation.registerFix(new EditSettingsAction(new ScssLintSettingsPage(file.getProject())));
        annotation.setFileLevelAnnotation(true);
        return;
    }
    // TODO consider adding a fix to edit configuration file
    if (annotationResult.result == null || annotationResult.result.lint == null || annotationResult.result.lint.isEmpty()) {
        return;
    }
    // String relativeFile = FileUtils.makeRelative(file.getProject(), file.getVirtualFile());
    List<Lint.Issue> issues = annotationResult.result.lint.values().iterator().next();
    if (issues == null) {
        return;
    }
    ScssLintProjectComponent component = annotationResult.input.project.getComponent(ScssLintProjectComponent.class);
    int tabSize = 4;
    for (Lint.Issue issue : issues) {
        HighlightSeverity severity = getHighlightSeverity(issue, component.treatAsWarnings);
        TextAttributes forcedTextAttributes = AnnotatorUtils.getTextAttributes(colorsScheme, severityRegistrar, severity);
        Annotation annotation = createAnnotation(holder, file, document, issue, "SCSS Lint: ", tabSize, severity, forcedTextAttributes, inspectionKey, false);
        if (annotation != null) {
            int offset = StringUtil.lineColToOffset(document.getText(), issue.line - 1, issue.column);
            PsiElement lit = PsiUtil.getElementAtOffset(file, offset);
            BaseActionFix actionFix = Fixes.getFixForRule(issue.linter, lit);
            if (actionFix != null) {
                annotation.registerFix(actionFix, null, inspectionKey);
            }
        //                annotation.registerFix(new SuppressActionFix(issue.rule, lit), null, inspectionKey);
        }
    }
}
Also used : HighlightSeverity(com.intellij.lang.annotation.HighlightSeverity) HighlightDisplayKey(com.intellij.codeInsight.daemon.HighlightDisplayKey) Lint(com.scss.utils.scssLint.Lint) ScssLintSettingsPage(com.scss.settings.ScssLintSettingsPage) Document(com.intellij.openapi.editor.Document) Annotation(com.intellij.lang.annotation.Annotation) Lint(com.scss.utils.scssLint.Lint) TextAttributes(com.intellij.openapi.editor.markup.TextAttributes) EditorColorsScheme(com.intellij.openapi.editor.colors.EditorColorsScheme) InspectionProjectProfileManager(com.intellij.profile.codeInspection.InspectionProjectProfileManager) SeverityRegistrar(com.intellij.codeInsight.daemon.impl.SeverityRegistrar) PsiElement(com.intellij.psi.PsiElement) BaseActionFix(com.scss.annotator.BaseActionFix)

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