use of com.intellij.codeInsight.unwrap.UnwrapHandler in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoUnwrapTestCase method assertUnwrapped.
protected void assertUnwrapped(@NotNull String codeBefore, @NotNull String codeAfter, int option) {
myFixture.configureByText("a.go", normalizeCode(codeBefore));
UnwrapHandler h = new UnwrapHandler() {
@Override
protected void selectOption(List<AnAction> options, Editor editor, PsiFile file) {
if (options.isEmpty())
return;
options.get(option).actionPerformed(null);
}
};
h.invoke(getProject(), myFixture.getEditor(), myFixture.getFile());
myFixture.checkResult(normalizeCode(codeAfter));
}
use of com.intellij.codeInsight.unwrap.UnwrapHandler in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoUnwrapTestCase method assertOptions.
protected void assertOptions(@NotNull String code, String... expectedOptions) {
myFixture.configureByText("a.go", normalizeCode(code));
List<String> actualOptions = ContainerUtil.newArrayList();
UnwrapHandler h = new UnwrapHandler() {
@Override
protected void selectOption(List<AnAction> options, Editor editor, PsiFile file) {
actualOptions.addAll(options.stream().map(each -> each.getTemplatePresentation().getText()).collect(Collectors.toList()));
}
};
h.invoke(getProject(), myFixture.getEditor(), myFixture.getFile());
assertOrderedEquals(actualOptions, expectedOptions);
}
use of com.intellij.codeInsight.unwrap.UnwrapHandler in project intellij-community by JetBrains.
the class PyUnwrapperTest method doNegativeTest.
private void doNegativeTest() {
String before = "refactoring/unwrap/" + getTestName(true) + "_before.py";
myFixture.configureByFile(before);
UnwrapHandler h = new UnwrapHandler() {
@Override
protected void selectOption(List<AnAction> options, Editor editor, PsiFile file) {
assertEmpty(options);
}
};
h.invoke(myFixture.getProject(), myFixture.getEditor(), myFixture.getFile());
}
use of com.intellij.codeInsight.unwrap.UnwrapHandler in project intellij-community by JetBrains.
the class PyUnwrapperTest method doTest.
private void doTest(final int option) {
String before = "refactoring/unwrap/" + getTestName(true) + "_before.py";
String after = "refactoring/unwrap/" + getTestName(true) + "_after.py";
myFixture.configureByFile(before);
UnwrapHandler h = new UnwrapHandler() {
@Override
protected void selectOption(List<AnAction> options, Editor editor, PsiFile file) {
assertTrue("No available options to unwrap", !options.isEmpty());
options.get(option).actionPerformed(null);
}
};
h.invoke(myFixture.getProject(), myFixture.getEditor(), myFixture.getFile());
myFixture.checkResultByFile(after, true);
}
use of com.intellij.codeInsight.unwrap.UnwrapHandler in project intellij-community by JetBrains.
the class PyUnwrapperTest method doNegativeTest.
private void doNegativeTest(final String optionName) {
String before = "refactoring/unwrap/" + getTestName(true) + "_before.py";
myFixture.configureByFile(before);
UnwrapHandler h = new UnwrapHandler() {
@Override
protected void selectOption(List<AnAction> options, Editor editor, PsiFile file) {
for (AnAction option : options) {
assertFalse("\"" + optionName + "\" is available to unwrap ", option.toString().contains(optionName));
}
}
};
h.invoke(myFixture.getProject(), myFixture.getEditor(), myFixture.getFile());
}
Aggregations