Search in sources :

Example 16 with HighlightInfoType

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

the class HighlightUtil method checkUnhandledCloserExceptions.

@Nullable
static HighlightInfo checkUnhandledCloserExceptions(@NotNull PsiResourceListElement resource) {
    List<PsiClassType> unhandled = ExceptionUtil.getUnhandledCloserExceptions(resource, null);
    if (unhandled.isEmpty())
        return null;
    HighlightInfoType highlightType = getUnhandledExceptionHighlightType(resource);
    if (highlightType == null)
        return null;
    String description = getUnhandledExceptionsDescriptor(unhandled, "auto-closeable resource");
    HighlightInfo highlight = HighlightInfo.newHighlightInfo(highlightType).range(resource).descriptionAndTooltip(description).create();
    registerUnhandledExceptionFixes(resource, highlight, unhandled);
    return highlight;
}
Also used : HighlightInfo(com.intellij.codeInsight.daemon.impl.HighlightInfo) HighlightInfoType(com.intellij.codeInsight.daemon.impl.HighlightInfoType)

Example 17 with HighlightInfoType

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

the class ProblemDescriptorUtil method highlightTypeFromDescriptor.

@NotNull
public static HighlightInfoType highlightTypeFromDescriptor(@NotNull ProblemDescriptor problemDescriptor, @NotNull HighlightSeverity severity, @NotNull SeverityRegistrar severityRegistrar) {
    final ProblemHighlightType highlightType = problemDescriptor.getHighlightType();
    final HighlightInfoType highlightInfoType = getHighlightInfoType(highlightType, severity, severityRegistrar);
    if (highlightInfoType == HighlightSeverity.INFORMATION) {
        final TextAttributesKey attributes = ((ProblemDescriptorBase) problemDescriptor).getEnforcedTextAttributes();
        if (attributes != null) {
            return new HighlightInfoType.HighlightInfoTypeImpl(HighlightSeverity.INFORMATION, attributes);
        }
    }
    return highlightInfoType;
}
Also used : TextAttributesKey(com.intellij.openapi.editor.colors.TextAttributesKey) HighlightInfoType(com.intellij.codeInsight.daemon.impl.HighlightInfoType) NotNull(org.jetbrains.annotations.NotNull)

Example 18 with HighlightInfoType

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

the class ApplicationInspectionProfileManager method registerProvidedSeverities.

// It should be public to be available from Upsource
public static void registerProvidedSeverities() {
    for (SeveritiesProvider provider : Extensions.getExtensions(SeveritiesProvider.EP_NAME)) {
        for (HighlightInfoType t : provider.getSeveritiesHighlightInfoTypes()) {
            HighlightSeverity highlightSeverity = t.getSeverity(null);
            SeverityRegistrar.registerStandard(t, highlightSeverity);
            TextAttributesKey attributesKey = t.getAttributesKey();
            Icon icon = t instanceof HighlightInfoType.Iconable ? ((HighlightInfoType.Iconable) t).getIcon() : null;
            HighlightDisplayLevel.registerSeverity(highlightSeverity, attributesKey, icon);
        }
    }
}
Also used : HighlightSeverity(com.intellij.lang.annotation.HighlightSeverity) TextAttributesKey(com.intellij.openapi.editor.colors.TextAttributesKey) SeveritiesProvider(com.intellij.codeInsight.daemon.impl.SeveritiesProvider) HighlightInfoType(com.intellij.codeInsight.daemon.impl.HighlightInfoType)

Example 19 with HighlightInfoType

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

the class LevelChooserAction method createPopupActionGroup.

@NotNull
@Override
public DefaultActionGroup createPopupActionGroup(final JComponent anchor) {
    final DefaultActionGroup group = new DefaultActionGroup();
    for (final HighlightSeverity severity : getSeverities(mySeverityRegistrar, myIncludeDoNotShow)) {
        final HighlightSeverityAction action = new HighlightSeverityAction(severity);
        if (myChosen == null) {
            setChosen(action.getSeverity());
        }
        group.add(action);
    }
    group.addSeparator();
    group.add(new DumbAwareAction("Edit severities...") {

        @Override
        public void actionPerformed(@NotNull final AnActionEvent e) {
            final SeverityEditorDialog dlg = new SeverityEditorDialog(anchor, myChosen, mySeverityRegistrar, true);
            if (dlg.showAndGet()) {
                final HighlightInfoType type = dlg.getSelectedType();
                if (type != null) {
                    final HighlightSeverity severity = type.getSeverity(null);
                    setChosen(severity);
                    onChosen(severity);
                }
            }
        }
    });
    return group;
}
Also used : HighlightSeverity(com.intellij.lang.annotation.HighlightSeverity) SeverityEditorDialog(com.intellij.codeInspection.ex.SeverityEditorDialog) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup) DumbAwareAction(com.intellij.openapi.project.DumbAwareAction) HighlightInfoType(com.intellij.codeInsight.daemon.impl.HighlightInfoType) NotNull(org.jetbrains.annotations.NotNull)

Example 20 with HighlightInfoType

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

the class GeneralColorsPage method getCustomSeveritiesDemoText.

private static String getCustomSeveritiesDemoText() {
    final StringBuilder buff = new StringBuilder();
    for (SeveritiesProvider provider : Extensions.getExtensions(SeveritiesProvider.EP_NAME)) {
        for (HighlightInfoType highlightInfoType : provider.getSeveritiesHighlightInfoTypes()) {
            final String tag = getHighlightDescTagName(highlightInfoType);
            buff.append("  <").append(tag).append(">");
            buff.append(tag.toLowerCase());
            buff.append("</").append(tag).append(">").append("\n");
        }
    }
    return buff.toString();
}
Also used : SeveritiesProvider(com.intellij.codeInsight.daemon.impl.SeveritiesProvider) HighlightInfoType(com.intellij.codeInsight.daemon.impl.HighlightInfoType)

Aggregations

HighlightInfoType (com.intellij.codeInsight.daemon.impl.HighlightInfoType)22 HighlightInfo (com.intellij.codeInsight.daemon.impl.HighlightInfo)14 TextRange (com.intellij.openapi.util.TextRange)8 Nullable (org.jetbrains.annotations.Nullable)6 TextAttributes (com.intellij.openapi.editor.markup.TextAttributes)5 TextAttributesKey (com.intellij.openapi.editor.colors.TextAttributesKey)4 SeveritiesProvider (com.intellij.codeInsight.daemon.impl.SeveritiesProvider)3 NotNull (org.jetbrains.annotations.NotNull)3 IntentionAction (com.intellij.codeInsight.intention.IntentionAction)2 HighlightSeverity (com.intellij.lang.annotation.HighlightSeverity)2 HtmlTag (com.intellij.psi.html.HtmlTag)2 MethodCandidateInfo (com.intellij.psi.infos.MethodCandidateInfo)2 AnyXmlElementDescriptor (com.intellij.xml.impl.schema.AnyXmlElementDescriptor)2 QuickFixActionRegistrarImpl (com.intellij.codeInsight.daemon.impl.quickfix.QuickFixActionRegistrarImpl)1 SeverityEditorDialog (com.intellij.codeInspection.ex.SeverityEditorDialog)1 ASTNode (com.intellij.lang.ASTNode)1 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)1 DefaultActionGroup (com.intellij.openapi.actionSystem.DefaultActionGroup)1 Module (com.intellij.openapi.module.Module)1 AttributesDescriptor (com.intellij.openapi.options.colors.AttributesDescriptor)1