use of com.intellij.codeInspection.ex.QuickFixWrapper in project intellij-plugins by JetBrains.
the class CucumberJavaCreateStepTest method doTest.
private void doTest(boolean createAll) {
CucumberStepsIndex.getInstance(getProject()).reset();
myFixture.enableInspections(new CucumberStepInspection());
myFixture.copyDirectoryToProject("createStep/" + getTestName(true), "");
myFixture.configureByFile("createStep/" + getTestName(true) + "/test.feature");
myFixture.checkHighlighting(true, false, false);
final String fixName = createAll ? "Create All" : "Create step";
final IntentionAction quickFix = ContainerUtil.find(myFixture.getAvailableIntentions(), intentionAction -> intentionAction instanceof QuickFixWrapper && intentionAction.getText().contains(fixName));
if (quickFix != null) {
myFixture.launchAction(quickFix);
VirtualFile expectedFile = myFixture.findFileInTempDir("StepDefs.java");
myFixture.openFileInEditor(expectedFile);
myFixture.checkResultByFile("createStep/" + getTestName(true) + "/StepDefs_fixed.txt");
}
}
use of com.intellij.codeInspection.ex.QuickFixWrapper in project intellij-community by JetBrains.
the class MigrateAssertToMatcherAssertTest method testAll.
public void testAll() {
myFixture.configureByFile(getTestName(true) + ".java");
myFixture.enableInspections(new MigrateAssertToMatcherAssertInspection());
for (IntentionAction wrapper : myFixture.getAllQuickFixes()) {
if (wrapper instanceof QuickFixWrapper) {
final LocalQuickFix fix = ((QuickFixWrapper) wrapper).getFix();
if (fix instanceof MigrateAssertToMatcherAssertInspection.MyQuickFix) {
myFixture.launchAction(wrapper);
}
}
}
myFixture.checkResultByFile(getTestName(true) + "_after.java");
}
use of com.intellij.codeInspection.ex.QuickFixWrapper in project intellij-community by JetBrains.
the class SuperClassHasFrequentlyUsedInheritorsInspectionTest method doTest.
private void doTest(final Pair<String, Integer>... expectedResults) {
myFixture.configureByFile(getTestName(false) + ".java");
myFixture.enableInspections(SuperClassHasFrequentlyUsedInheritorsInspection.class);
final Set<Pair<String, Integer>> actualSet = new HashSet<Pair<String, Integer>>();
for (IntentionAction intentionAction : myFixture.getAvailableIntentions()) {
if (intentionAction instanceof QuickFixWrapper) {
ChangeSuperClassFix changeSuperClassFix = getQuickFixFromWrapper((QuickFixWrapper) intentionAction);
if (changeSuperClassFix != null) {
actualSet.add(Pair.create(changeSuperClassFix.getNewSuperClass().getQualifiedName(), changeSuperClassFix.getPercent()));
}
}
}
final Set<Pair<String, Integer>> expectedSet = ContainerUtil.newHashSet(expectedResults);
assertEquals(actualSet, expectedSet);
}
use of com.intellij.codeInspection.ex.QuickFixWrapper in project intellij-community by JetBrains.
the class AddImportQuickFixTest method doMultiFileAutoImportTest.
private void doMultiFileAutoImportTest(@NotNull String hintPrefix, @Nullable Processor<AutoImportQuickFix> checkQuickfix) {
myFixture.copyDirectoryToProject(getTestName(true), "");
myFixture.enableInspections(PyUnresolvedReferencesInspection.class);
final String entryPoint = "main";
myFixture.configureByFile(entryPoint + ".py");
myFixture.checkHighlighting(true, false, false);
final List<IntentionAction> intentions = myFixture.filterAvailableIntentions(hintPrefix);
final IntentionAction intention = ContainerUtil.find(intentions, action -> {
return action instanceof QuickFixWrapper && ((QuickFixWrapper) action).getFix() instanceof AutoImportQuickFix;
});
assertNotNull("Auto import quick fix starting with '" + hintPrefix + "' wasn't found", intention);
final AutoImportQuickFix quickfix = (AutoImportQuickFix) ((QuickFixWrapper) intention).getFix();
boolean applyFix = true;
if (checkQuickfix != null) {
applyFix = checkQuickfix.process(quickfix);
}
if (applyFix) {
myFixture.launchAction(intention);
myFixture.checkResultByFile(getTestName(true) + "/" + entryPoint + "_after.py", true);
}
}
Aggregations