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>");
}
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);
}
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);
}
}
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);
}
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");
}
Aggregations