Search in sources :

Example 6 with HighlightSeverity

use of com.intellij.lang.annotation.HighlightSeverity 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 7 with HighlightSeverity

use of com.intellij.lang.annotation.HighlightSeverity 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 8 with HighlightSeverity

use of com.intellij.lang.annotation.HighlightSeverity in project intellij-community by JetBrains.

the class SeverityRegistrar method fromList.

@NotNull
private static OrderMap fromList(@NotNull List<HighlightSeverity> orderList) {
    if (orderList.size() != new HashSet<>(orderList).size()) {
        LOG.error("Severities order list MUST contain only unique severities: " + orderList);
    }
    TObjectIntHashMap<HighlightSeverity> map = new TObjectIntHashMap<>();
    for (int i = 0; i < orderList.size(); i++) {
        HighlightSeverity severity = orderList.get(i);
        map.put(severity, i);
    }
    return new OrderMap(map);
}
Also used : HighlightSeverity(com.intellij.lang.annotation.HighlightSeverity) TObjectIntHashMap(gnu.trove.TObjectIntHashMap) NotNull(org.jetbrains.annotations.NotNull)

Example 9 with HighlightSeverity

use of com.intellij.lang.annotation.HighlightSeverity in project intellij-community by JetBrains.

the class SeverityRegistrar method registerSeverity.

public void registerSeverity(@NotNull SeverityBasedTextAttributes info, Color renderColor) {
    final HighlightSeverity severity = info.getType().getSeverity(null);
    myMap.put(severity.getName(), info);
    if (renderColor != null) {
        myRendererColors.put(severity.getName(), renderColor);
    }
    myOrderMap = null;
    HighlightDisplayLevel.registerSeverity(severity, getHighlightInfoTypeBySeverity(severity).getAttributesKey(), null);
    severitiesChanged();
}
Also used : HighlightSeverity(com.intellij.lang.annotation.HighlightSeverity)

Example 10 with HighlightSeverity

use of com.intellij.lang.annotation.HighlightSeverity in project intellij-community by JetBrains.

the class SeverityRegistrar method readExternal.

public void readExternal(@NotNull Element element) {
    myMap.clear();
    myRendererColors.clear();
    for (Element infoElement : element.getChildren(INFO_TAG)) {
        SeverityBasedTextAttributes highlightInfo = new SeverityBasedTextAttributes(infoElement);
        String colorStr = infoElement.getAttributeValue(COLOR_ATTRIBUTE);
        @SuppressWarnings("UseJBColor") Color color = colorStr == null ? null : new Color(Integer.parseInt(colorStr, 16));
        registerSeverity(highlightInfo, color);
    }
    myReadOrder = new JDOMExternalizableStringList();
    myReadOrder.readExternal(element);
    List<HighlightSeverity> read = new ArrayList<>(myReadOrder.size());
    final List<HighlightSeverity> knownSeverities = getDefaultOrder();
    for (String name : myReadOrder) {
        HighlightSeverity severity = getSeverity(name);
        if (severity != null && knownSeverities.contains(severity)) {
            read.add(severity);
        }
    }
    myOrderMap = ensureAllStandardIncluded(read, knownSeverities);
    severitiesChanged();
}
Also used : HighlightSeverity(com.intellij.lang.annotation.HighlightSeverity) JDOMExternalizableStringList(com.intellij.openapi.util.JDOMExternalizableStringList) Element(org.jdom.Element)

Aggregations

HighlightSeverity (com.intellij.lang.annotation.HighlightSeverity)31 Element (org.jdom.Element)8 TextAttributes (com.intellij.openapi.editor.markup.TextAttributes)7 HighlightInfoType (com.intellij.codeInsight.daemon.impl.HighlightInfoType)6 NotNull (org.jetbrains.annotations.NotNull)6 HighlightDisplayLevel (com.intellij.codeHighlighting.HighlightDisplayLevel)5 SeverityRegistrar (com.intellij.codeInsight.daemon.impl.SeverityRegistrar)5 TextAttributesKey (com.intellij.openapi.editor.colors.TextAttributesKey)5 Nullable (org.jetbrains.annotations.Nullable)4 Annotation (com.intellij.lang.annotation.Annotation)3 TextRange (com.intellij.openapi.util.TextRange)3 HighlightDisplayKey (com.intellij.codeInsight.daemon.HighlightDisplayKey)2 IntentionAction (com.intellij.codeInsight.intention.IntentionAction)2 Document (com.intellij.openapi.editor.Document)2 DumbAwareAction (com.intellij.openapi.project.DumbAwareAction)2 Project (com.intellij.openapi.project.Project)2 JDOMExternalizableStringList (com.intellij.openapi.util.JDOMExternalizableStringList)2 PsiElement (com.intellij.psi.PsiElement)2 THashSet (gnu.trove.THashSet)2 NonNls (org.jetbrains.annotations.NonNls)2