Search in sources :

Example 1 with ProblemGroup

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

the class GlobalInspectionContextImpl method getProblemDescriptionProcessor.

@NotNull
private ProblemDescriptionsProcessor getProblemDescriptionProcessor(@NotNull final GlobalInspectionToolWrapper toolWrapper, @NotNull final Map<String, InspectionToolWrapper> wrappersMap) {
    return new ProblemDescriptionsProcessor() {

        @Override
        public void addProblemElement(@Nullable RefEntity refEntity, @NotNull CommonProblemDescriptor... commonProblemDescriptors) {
            for (CommonProblemDescriptor problemDescriptor : commonProblemDescriptors) {
                if (!(problemDescriptor instanceof ProblemDescriptor)) {
                    continue;
                }
                ProblemGroup problemGroup = ((ProblemDescriptor) problemDescriptor).getProblemGroup();
                InspectionToolWrapper targetWrapper = problemGroup == null ? toolWrapper : wrappersMap.get(problemGroup.getProblemName());
                if (targetWrapper != null) {
                    // Else it's switched off
                    InspectionToolPresentation toolPresentation = getPresentation(targetWrapper);
                    toolPresentation.addProblemElement(refEntity, problemDescriptor);
                }
            }
        }
    };
}
Also used : DefaultInspectionToolPresentation(com.intellij.codeInspection.ui.DefaultInspectionToolPresentation) InspectionToolPresentation(com.intellij.codeInspection.ui.InspectionToolPresentation) RefEntity(com.intellij.codeInspection.reference.RefEntity) ProblemGroup(com.intellij.lang.annotation.ProblemGroup) NotNull(org.jetbrains.annotations.NotNull) Nullable(org.jetbrains.annotations.Nullable) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with ProblemGroup

use of com.intellij.lang.annotation.ProblemGroup in project kotlin by JetBrains.

the class AbstractQuickFixTest method findActionWithText.

@Override
protected IntentionAction findActionWithText(String text) {
    IntentionAction intention = super.findActionWithText(text);
    if (intention != null)
        return intention;
    // Support warning suppression
    int caretOffset = myEditor.getCaretModel().getOffset();
    for (HighlightInfo highlight : doHighlighting()) {
        if (highlight.startOffset <= caretOffset && caretOffset <= highlight.endOffset) {
            ProblemGroup group = highlight.getProblemGroup();
            if (group instanceof SuppressableProblemGroup) {
                SuppressableProblemGroup problemGroup = (SuppressableProblemGroup) group;
                PsiElement at = getFile().findElementAt(highlight.getActualStartOffset());
                SuppressIntentionAction[] actions = problemGroup.getSuppressActions(at);
                for (SuppressIntentionAction action : actions) {
                    if (action.getText().equals(text)) {
                        return action;
                    }
                }
            }
        }
    }
    return null;
}
Also used : SuppressableProblemGroup(com.intellij.codeInspection.SuppressableProblemGroup) SuppressIntentionAction(com.intellij.codeInspection.SuppressIntentionAction) IntentionAction(com.intellij.codeInsight.intention.IntentionAction) HighlightInfo(com.intellij.codeInsight.daemon.impl.HighlightInfo) SuppressableProblemGroup(com.intellij.codeInspection.SuppressableProblemGroup) ProblemGroup(com.intellij.lang.annotation.ProblemGroup) SuppressIntentionAction(com.intellij.codeInspection.SuppressIntentionAction) PsiElement(com.intellij.psi.PsiElement)

Aggregations

ProblemGroup (com.intellij.lang.annotation.ProblemGroup)2 HighlightInfo (com.intellij.codeInsight.daemon.impl.HighlightInfo)1 IntentionAction (com.intellij.codeInsight.intention.IntentionAction)1 SuppressIntentionAction (com.intellij.codeInspection.SuppressIntentionAction)1 SuppressableProblemGroup (com.intellij.codeInspection.SuppressableProblemGroup)1 RefEntity (com.intellij.codeInspection.reference.RefEntity)1 DefaultInspectionToolPresentation (com.intellij.codeInspection.ui.DefaultInspectionToolPresentation)1 InspectionToolPresentation (com.intellij.codeInspection.ui.InspectionToolPresentation)1 PsiElement (com.intellij.psi.PsiElement)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1