use of com.intellij.codeInsight.intention.IntentionAction in project intellij-plugins by JetBrains.
the class DartServerQuickFixTest method doQuickFixTest.
/**
* @param fileUpdatedByFix <code>null</code> if quick fix updates the file from which it was invoked
*/
private void doQuickFixTest(@NotNull final String intentionStartText, @Nullable final VirtualFile fileUpdatedByFix, boolean fixAvailable) {
myFixture.configureByFile(getTestName(false) + ".dart");
final IntentionAction quickFix = myFixture.findSingleIntention(intentionStartText);
assertEquals(fixAvailable, quickFix.isAvailable(getProject(), getEditor(), getFile()));
if (!fixAvailable)
return;
if (fileUpdatedByFix != null) {
// todo This is a workaround because DartQuickFix.navigate() behaves differently in test environment.
// Would be great to remove this code and instead check that correct editor becomes open after fix.invoke()
myFixture.openFileInEditor(fileUpdatedByFix);
}
ApplicationManager.getApplication().runWriteAction(() -> quickFix.invoke(getProject(), getEditor(), getFile()));
final String updatedFileName = fileUpdatedByFix == null ? getTestName(false) : fileUpdatedByFix.getNameWithoutExtension();
myFixture.checkResultByFile(updatedFileName + ".after.dart");
}
use of com.intellij.codeInsight.intention.IntentionAction in project android by JetBrains.
the class LintIdeApiDetectorTest method doTest.
private void doTest(@NotNull final AndroidLintInspectionBase inspection, @Nullable String quickFixName, boolean createManifest) throws Exception {
if (createManifest) {
createManifest();
}
myFixture.enableInspections(inspection);
VirtualFile file = myFixture.copyFileToProject(BASE_PATH + getTestName(false) + ".java", "src/p1/p2/Class.java");
myFixture.configureFromExistingVirtualFile(file);
myFixture.checkHighlighting(true, false, false);
if (quickFixName != null) {
IntentionAction quickFix = AndroidTestUtils.getIntentionAction(myFixture, quickFixName);
assertNotNull(quickFix);
myFixture.launchAction(quickFix);
myFixture.checkResultByFile(BASE_PATH + getTestName(false) + "_after.java");
}
}
use of com.intellij.codeInsight.intention.IntentionAction in project android by JetBrains.
the class LintIdeGradleDetectorTest method doTest.
private void doTest(@NotNull final AndroidLintInspectionBase inspection, @Nullable String quickFixName) throws Exception {
createManifest();
myFixture.enableInspections(inspection);
VirtualFile file = myFixture.copyFileToProject(BASE_PATH + getTestName(false) + ".gradle", "build.gradle");
myFixture.configureFromExistingVirtualFile(file);
myFixture.checkHighlighting(true, false, false);
if (quickFixName != null) {
final IntentionAction quickFix = myFixture.getAvailableIntention(quickFixName);
assertNotNull(quickFix);
myFixture.launchAction(quickFix);
myFixture.checkResultByFile(BASE_PATH + getTestName(false) + "_after.gradle");
}
}
use of com.intellij.codeInsight.intention.IntentionAction in project android by JetBrains.
the class RegisterComponentsTest method testAddActivityNoShow.
/**
* Test that "add activity" doesn't show up when activity is already registered
*/
public void testAddActivityNoShow() throws Exception {
deleteManifest();
myFixture.copyFileToProject("intentions/DummyActivity_manifest_after.xml", "AndroidManifest.xml");
final VirtualFile file = myFixture.copyFileToProject("intentions/DummyActivity.java", "src/com/example/DummyActivity.java");
myFixture.configureFromExistingVirtualFile(file);
final IntentionAction action = AndroidTestUtils.getIntentionAction(myFixture, ADD_ACTIVITY_TO_MANIFEST);
assertNull(action);
}
use of com.intellij.codeInsight.intention.IntentionAction in project android by JetBrains.
the class AndroidDomTestCase method doTestSpellcheckerQuickFixes.
protected final void doTestSpellcheckerQuickFixes() throws IOException {
myFixture.enableInspections(SpellCheckingInspection.class);
// TODO: Kill getTestName, make test classes specify the golden file explicitly.
VirtualFile virtualFile = copyFileToProject(getTestName(true) + ".xml");
myFixture.configureFromExistingVirtualFile(virtualFile);
List<IntentionAction> fixes = highlightAndFindQuickFixes(null);
assertEquals(2, fixes.size());
assertInstanceOf(((QuickFixWrapper) fixes.get(0)).getFix(), RenameTo.class);
assertInstanceOf(((QuickFixWrapper) fixes.get(1)).getFix(), AcceptWordAsCorrect.class);
}
Aggregations