Search in sources :

Example 1 with UnwrapHandler

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));
}
Also used : UnwrapHandler(com.intellij.codeInsight.unwrap.UnwrapHandler) List(java.util.List) PsiFile(com.intellij.psi.PsiFile) Editor(com.intellij.openapi.editor.Editor)

Example 2 with UnwrapHandler

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);
}
Also used : UnwrapHandler(com.intellij.codeInsight.unwrap.UnwrapHandler) List(java.util.List) PsiFile(com.intellij.psi.PsiFile) Editor(com.intellij.openapi.editor.Editor)

Example 3 with UnwrapHandler

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());
}
Also used : UnwrapHandler(com.intellij.codeInsight.unwrap.UnwrapHandler) List(java.util.List) PsiFile(com.intellij.psi.PsiFile) Editor(com.intellij.openapi.editor.Editor)

Example 4 with UnwrapHandler

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);
}
Also used : UnwrapHandler(com.intellij.codeInsight.unwrap.UnwrapHandler) List(java.util.List) PsiFile(com.intellij.psi.PsiFile) Editor(com.intellij.openapi.editor.Editor)

Example 5 with UnwrapHandler

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());
}
Also used : UnwrapHandler(com.intellij.codeInsight.unwrap.UnwrapHandler) List(java.util.List) PsiFile(com.intellij.psi.PsiFile) Editor(com.intellij.openapi.editor.Editor) AnAction(com.intellij.openapi.actionSystem.AnAction)

Aggregations

UnwrapHandler (com.intellij.codeInsight.unwrap.UnwrapHandler)5 Editor (com.intellij.openapi.editor.Editor)5 PsiFile (com.intellij.psi.PsiFile)5 List (java.util.List)5 AnAction (com.intellij.openapi.actionSystem.AnAction)1