Search in sources :

Example 1 with IntentionAction

use of com.intellij.codeInsight.intention.IntentionAction in project intellij-community by JetBrains.

the class PyTestCase method findQuickFixByClassInIntentions.

/**
   * Searches for quickfix itetion by its class
   *
   * @param clazz quick fix class
   * @param <T>   quick fix class
   * @return quick fix or null if nothing found
   */
@Nullable
public <T extends LocalQuickFix> T findQuickFixByClassInIntentions(@NotNull final Class<T> clazz) {
    for (final IntentionAction action : myFixture.getAvailableIntentions()) {
        if ((action instanceof QuickFixWrapper)) {
            final QuickFixWrapper quickFixWrapper = (QuickFixWrapper) action;
            final LocalQuickFix fix = quickFixWrapper.getFix();
            if (clazz.isInstance(fix)) {
                @SuppressWarnings("unchecked") final T result = (T) fix;
                return result;
            }
        }
    }
    return null;
}
Also used : IntentionAction(com.intellij.codeInsight.intention.IntentionAction) LocalQuickFix(com.intellij.codeInspection.LocalQuickFix) QuickFixWrapper(com.intellij.codeInspection.ex.QuickFixWrapper) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with IntentionAction

use of com.intellij.codeInsight.intention.IntentionAction in project intellij-community by JetBrains.

the class SpellingPopupActionGroup method extractActions.

private static void extractActions(List<HighlightInfo.IntentionActionDescriptor> descriptors, Map<Anchor, List<AnAction>> actions) {
    for (HighlightInfo.IntentionActionDescriptor actionDescriptor : descriptors) {
        IntentionAction action = actionDescriptor.getAction();
        if (action instanceof QuickFixWrapper) {
            QuickFixWrapper wrapper = (QuickFixWrapper) action;
            LocalQuickFix localQuickFix = wrapper.getFix();
            if (localQuickFix instanceof SpellCheckerQuickFix) {
                SpellCheckerQuickFix spellCheckerQuickFix = (SpellCheckerQuickFix) localQuickFix;
                Anchor anchor = spellCheckerQuickFix.getPopupActionAnchor();
                SpellCheckerIntentionAction popupAction = new SpellCheckerIntentionAction(action);
                List<AnAction> list = actions.get(anchor);
                if (list != null) {
                    list.add(popupAction);
                }
            }
        }
    }
}
Also used : SpellCheckerQuickFix(com.intellij.spellchecker.quickfixes.SpellCheckerQuickFix) IntentionAction(com.intellij.codeInsight.intention.IntentionAction) HighlightInfo(com.intellij.codeInsight.daemon.impl.HighlightInfo) LocalQuickFix(com.intellij.codeInspection.LocalQuickFix) QuickFixWrapper(com.intellij.codeInspection.ex.QuickFixWrapper)

Example 3 with IntentionAction

use of com.intellij.codeInsight.intention.IntentionAction in project intellij-community by JetBrains.

the class PyUnresolvedReferencesInspectionTest method testIgnoredUnresolvedReferenceInUnionType.

// PY-11956
public void testIgnoredUnresolvedReferenceInUnionType() {
    final String testName = getTestName(true);
    final String inspectionName = getInspectionClass().getSimpleName();
    myFixture.configureByFile("inspections/" + inspectionName + "/" + testName + ".py");
    myFixture.enableInspections(getInspectionClass());
    final String attrQualifiedName = "inspections." + inspectionName + "." + testName + ".A.foo";
    final IntentionAction intentionAction = myFixture.findSingleIntention("Ignore unresolved reference '" + attrQualifiedName + "'");
    assertNotNull(intentionAction);
    myFixture.launchAction(intentionAction);
    myFixture.checkHighlighting(isWarning(), isInfo(), isWeakWarning());
}
Also used : IntentionAction(com.intellij.codeInsight.intention.IntentionAction)

Example 4 with IntentionAction

use of com.intellij.codeInsight.intention.IntentionAction in project intellij-community by JetBrains.

the class PyIntentionTest method doTest.

private void doTest(String hint, boolean ignoreWhiteSpaces) {
    myFixture.configureByFile("intentions/" + getTestName(true) + ".py");
    final IntentionAction action = myFixture.findSingleIntention(hint);
    myFixture.launchAction(action);
    myFixture.checkResultByFile("intentions/" + getTestName(true) + "_after.py", ignoreWhiteSpaces);
}
Also used : IntentionAction(com.intellij.codeInsight.intention.IntentionAction)

Example 5 with IntentionAction

use of com.intellij.codeInsight.intention.IntentionAction in project intellij-community by JetBrains.

the class PyIntentionTest method doTest.

private void doTest(String hint) {
    myFixture.configureByFile("intentions/" + getTestName(true) + ".py");
    final IntentionAction action = myFixture.findSingleIntention(hint);
    myFixture.launchAction(action);
    myFixture.checkResultByFile("intentions/" + getTestName(true) + "_after.py");
}
Also used : IntentionAction(com.intellij.codeInsight.intention.IntentionAction)

Aggregations

IntentionAction (com.intellij.codeInsight.intention.IntentionAction)242 VirtualFile (com.intellij.openapi.vfs.VirtualFile)39 HighlightInfo (com.intellij.codeInsight.daemon.impl.HighlightInfo)31 NotNull (org.jetbrains.annotations.NotNull)23 Project (com.intellij.openapi.project.Project)20 TextRange (com.intellij.openapi.util.TextRange)20 Editor (com.intellij.openapi.editor.Editor)17 PsiFile (com.intellij.psi.PsiFile)17 Annotation (com.intellij.lang.annotation.Annotation)16 PsiElement (com.intellij.psi.PsiElement)16 Nullable (org.jetbrains.annotations.Nullable)15 ArrayList (java.util.ArrayList)14 LocalQuickFix (com.intellij.codeInspection.LocalQuickFix)10 QuickFixWrapper (com.intellij.codeInspection.ex.QuickFixWrapper)9 Pair (com.intellij.openapi.util.Pair)9 IncorrectOperationException (com.intellij.util.IncorrectOperationException)7 EmptyIntentionAction (com.intellij.codeInsight.intention.EmptyIntentionAction)6 AndroidMissingOnClickHandlerInspection (org.jetbrains.android.inspections.AndroidMissingOnClickHandlerInspection)6 HighlightDisplayLevel (com.intellij.codeHighlighting.HighlightDisplayLevel)5 HighlightDisplayKey (com.intellij.codeInsight.daemon.HighlightDisplayKey)5