Search in sources :

Example 1 with ListTemplatesAction

use of com.intellij.codeInsight.template.impl.actions.ListTemplatesAction in project intellij-community by JetBrains.

the class PyLiveTemplatesExpandingTest method doMultiFileTest.

private void doMultiFileTest() {
    myFixture.copyDirectoryToProject(getTestName(false), "");
    myFixture.configureByFile("a.py");
    final Editor editor = myFixture.getEditor();
    final Project project = myFixture.getProject();
    new ListTemplatesAction().actionPerformedImpl(project, editor);
    final LookupImpl lookup = (LookupImpl) LookupManager.getActiveLookup(editor);
    assertNotNull(lookup);
    lookup.finishLookup(Lookup.NORMAL_SELECT_CHAR);
    myFixture.checkResultByFile(getTestName(false) + "/a_after.py");
}
Also used : Project(com.intellij.openapi.project.Project) LookupImpl(com.intellij.codeInsight.lookup.impl.LookupImpl) Editor(com.intellij.openapi.editor.Editor) ListTemplatesAction(com.intellij.codeInsight.template.impl.actions.ListTemplatesAction)

Example 2 with ListTemplatesAction

use of com.intellij.codeInsight.template.impl.actions.ListTemplatesAction in project intellij-community by JetBrains.

the class ListTemplateActionTest method doTest.

private void doTest(@NotNull String lookupText) {
    myFixture.configureByFile(getTestName(false) + ".java");
    new ListTemplatesAction().actionPerformedImpl(myFixture.getProject(), myFixture.getEditor());
    LookupElement[] elements = myFixture.getLookupElements();
    assertNotNull(elements);
    for (LookupElement element : elements) {
        if (lookupText.equals(element.getLookupString())) {
            myFixture.getLookup().setCurrentItem(element);
            myFixture.finishLookup(Lookup.NORMAL_SELECT_CHAR);
            myFixture.checkResultByFile(getTestName(false) + "_after.java");
            return;
        }
    }
    //noinspection ConstantConditions
    fail("Lookup element with text '" + lookupText + "' not found:\n" + StringUtil.join(myFixture.getLookupElementStrings(), "\n"));
}
Also used : LookupElement(com.intellij.codeInsight.lookup.LookupElement) ListTemplatesAction(com.intellij.codeInsight.template.impl.actions.ListTemplatesAction)

Example 3 with ListTemplatesAction

use of com.intellij.codeInsight.template.impl.actions.ListTemplatesAction in project intellij-community by JetBrains.

the class ListTemplateActionTest method testWithSameKeys.

public void testWithSameKeys() {
    myFixture.configureByFile(getTestName(false) + ".java");
    new ListTemplatesAction().actionPerformedImpl(myFixture.getProject(), myFixture.getEditor());
    assertSameElements(myFixture.getLookupElementStrings(), "duplicateKey", "duplicateKey");
}
Also used : ListTemplatesAction(com.intellij.codeInsight.template.impl.actions.ListTemplatesAction)

Example 4 with ListTemplatesAction

use of com.intellij.codeInsight.template.impl.actions.ListTemplatesAction in project intellij-plugins by JetBrains.

the class DartLiveTemplatesTest method expandTemplate.

public void expandTemplate(final Editor editor) {
    final Project project = editor.getProject();
    assertNotNull(project);
    new ListTemplatesAction().actionPerformedImpl(project, editor);
    final LookupImpl lookup = (LookupImpl) LookupManager.getActiveLookup(editor);
    assertNotNull(lookup);
    lookup.finishLookup(Lookup.NORMAL_SELECT_CHAR);
    TemplateState template = TemplateManagerImpl.getTemplateState(editor);
    if (template != null) {
        Disposer.dispose(template);
    }
}
Also used : Project(com.intellij.openapi.project.Project) LookupImpl(com.intellij.codeInsight.lookup.impl.LookupImpl) ListTemplatesAction(com.intellij.codeInsight.template.impl.actions.ListTemplatesAction) TemplateState(com.intellij.codeInsight.template.impl.TemplateState)

Example 5 with ListTemplatesAction

use of com.intellij.codeInsight.template.impl.actions.ListTemplatesAction in project intellij-community by JetBrains.

the class CodeInsightTestUtil method doLiveTemplateTest.

public static void doLiveTemplateTest(@NotNull final CodeInsightTestFixture fixture, @NotNull final String before, @NotNull final String after) {
    fixture.configureByFile(before);
    new ListTemplatesAction().actionPerformedImpl(fixture.getProject(), fixture.getEditor());
    final LookupImpl lookup = (LookupImpl) LookupManager.getActiveLookup(fixture.getEditor());
    assert lookup != null;
    lookup.finishLookup(Lookup.NORMAL_SELECT_CHAR);
    fixture.checkResultByFile(after, false);
}
Also used : LookupImpl(com.intellij.codeInsight.lookup.impl.LookupImpl) ListTemplatesAction(com.intellij.codeInsight.template.impl.actions.ListTemplatesAction)

Aggregations

ListTemplatesAction (com.intellij.codeInsight.template.impl.actions.ListTemplatesAction)7 LookupImpl (com.intellij.codeInsight.lookup.impl.LookupImpl)5 Editor (com.intellij.openapi.editor.Editor)2 Project (com.intellij.openapi.project.Project)2 LookupElement (com.intellij.codeInsight.lookup.LookupElement)1 TemplateState (com.intellij.codeInsight.template.impl.TemplateState)1