Search in sources :

Example 1 with SuppressableProblemGroup

use of com.intellij.codeInspection.SuppressableProblemGroup 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

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 ProblemGroup (com.intellij.lang.annotation.ProblemGroup)1 PsiElement (com.intellij.psi.PsiElement)1