Search in sources :

Example 41 with IntentionAction

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

the class MavenModuleCompletionAndResolutionTest method testCreatePomQuickFixTakesGroupAndVersionFromSuperParent.

public void testCreatePomQuickFixTakesGroupAndVersionFromSuperParent() throws Throwable {
    createProjectPom("<groupId>test</groupId>" + "<artifactId>project</artifactId>" + "<version>1</version>" + "<packaging>pom</packaging>");
    importProject();
    createProjectPom("<artifactId>project</artifactId>" + "<packaging>pom</packaging>" + "<parent>" + "  <groupId>parentGroup</groupId>" + "  <artifactId>parent</artifactId>" + "  <version>parentVersion</version>" + "</parent>" + "<modules>" + "  <module>new<caret>Module</module>" + "</modules>");
    IntentionAction i = getIntentionAtCaret(CREATE_MODULE_INTENTION);
    assertNotNull(i);
    myFixture.launchAction(i);
    assertCreateModuleFixResult("newModule/pom.xml", "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<project xmlns=\"http://maven.apache.org/POM/4.0.0\"\n" + "         xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" + "         xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\">\n" + "    <modelVersion>4.0.0</modelVersion>\n" + "\n" + "    <groupId>parentGroup</groupId>\n" + "    <artifactId>newModule</artifactId>\n" + "    <version>parentVersion</version>\n" + "\n" + "    \n" + "</project>");
}
Also used : IntentionAction(com.intellij.codeInsight.intention.IntentionAction)

Example 42 with IntentionAction

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

the class CodeInsightTestUtil method doIntentionTest.

@TestOnly
public static void doIntentionTest(@NotNull final CodeInsightTestFixture fixture, @NonNls final String action, @NotNull final String before, @NotNull final String after) {
    fixture.configureByFile(before);
    List<IntentionAction> availableIntentions = fixture.getAvailableIntentions();
    final IntentionAction intentionAction = findIntentionByText(availableIntentions, action);
    if (intentionAction == null) {
        Assert.fail("Action not found: " + action + " in place: " + fixture.getElementAtCaret() + " among " + availableIntentions);
    }
    fixture.launchAction(intentionAction);
    fixture.checkResultByFile(after, false);
}
Also used : IntentionAction(com.intellij.codeInsight.intention.IntentionAction) TestOnly(org.jetbrains.annotations.TestOnly)

Example 43 with IntentionAction

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

the class HighlightMethodUtil method registerChangeMethodSignatureFromUsageIntention.

private static void registerChangeMethodSignatureFromUsageIntention(@NotNull PsiExpression[] expressions, @Nullable HighlightInfo highlightInfo, TextRange fixRange, @NotNull JavaResolveResult candidate, @NotNull PsiElement context) {
    if (!candidate.isStaticsScopeCorrect())
        return;
    PsiMethod method = (PsiMethod) candidate.getElement();
    PsiSubstitutor substitutor = candidate.getSubstitutor();
    if (method != null && context.getManager().isInProject(method)) {
        IntentionAction fix = QUICK_FIX_FACTORY.createChangeMethodSignatureFromUsageFix(method, expressions, substitutor, context, false, 2);
        QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, fix);
        IntentionAction f2 = QUICK_FIX_FACTORY.createChangeMethodSignatureFromUsageReverseOrderFix(method, expressions, substitutor, context, false, 2);
        QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, f2);
    }
}
Also used : IntentionAction(com.intellij.codeInsight.intention.IntentionAction)

Example 44 with IntentionAction

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

the class SuppressExternalTest method doTest.

private void doTest(String testName) throws Exception {
    final IntentionAction action = myFixture.getAvailableIntention("Suppress for method", "src/suppressed/" + testName + ".java");
    assertNotNull(action);
    Project project = myFixture.getProject();
    boolean oldUseExternalAnnotations = CodeStyleSettingsManager.getSettings(project).USE_EXTERNAL_ANNOTATIONS;
    try {
        CodeStyleSettingsManager.getSettings(project).USE_EXTERNAL_ANNOTATIONS = true;
        myFixture.launchAction(action);
    } finally {
        CodeStyleSettingsManager.getSettings(project).USE_EXTERNAL_ANNOTATIONS = oldUseExternalAnnotations;
    }
    myFixture.checkResultByFile("content/anno/suppressed/annotations.xml", "content/anno/suppressed/annotations" + testName + "_after.xml", true);
}
Also used : Project(com.intellij.openapi.project.Project) IntentionAction(com.intellij.codeInsight.intention.IntentionAction)

Example 45 with IntentionAction

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

the class GuavaInspectionTest method doTest.

private void doTest() {
    myFixture.configureByFile(getTestName(true) + ".java");
    myFixture.enableInspections(new GuavaInspection());
    boolean actionFound = false;
    myFixture.doHighlighting();
    for (IntentionAction action : myFixture.getAvailableIntentions()) {
        if (action instanceof GuavaInspection.MigrateGuavaTypeFix) {
            myFixture.launchAction(action);
            actionFound = true;
            break;
        }
    }
    assertTrue("Quick fix isn't found", actionFound);
    myFixture.checkResultByFile(getTestName(true) + "_after.java");
}
Also used : GuavaInspection(com.intellij.refactoring.typeMigration.inspections.GuavaInspection) IntentionAction(com.intellij.codeInsight.intention.IntentionAction)

Aggregations

IntentionAction (com.intellij.codeInsight.intention.IntentionAction)241 VirtualFile (com.intellij.openapi.vfs.VirtualFile)39 HighlightInfo (com.intellij.codeInsight.daemon.impl.HighlightInfo)31 NotNull (org.jetbrains.annotations.NotNull)22 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