Search in sources :

Example 36 with LookupImpl

use of com.intellij.codeInsight.lookup.impl.LookupImpl in project intellij-community by JetBrains.

the class JsonLiveTemplateTest method testCustomTemplateExpansion.

public void testCustomTemplateExpansion() {
    final String templateContent = "{\n" + "  \"foo\": \"$1$\"\n" + "}";
    createJsonTemplate("foo", "foo", templateContent);
    myFixture.configureByText(JsonFileType.INSTANCE, "foo<caret>");
    final Editor editor = myFixture.getEditor();
    new ListTemplatesAction().actionPerformedImpl(getProject(), editor);
    final LookupImpl lookup = (LookupImpl) LookupManager.getActiveLookup(editor);
    assertNotNull(lookup);
    lookup.finishLookup(Lookup.NORMAL_SELECT_CHAR);
    myFixture.checkResult(templateContent.replaceAll("\\$.*?\\$", ""));
}
Also used : LookupImpl(com.intellij.codeInsight.lookup.impl.LookupImpl) Editor(com.intellij.openapi.editor.Editor) ListTemplatesAction(com.intellij.codeInsight.template.impl.actions.ListTemplatesAction)

Example 37 with LookupImpl

use of com.intellij.codeInsight.lookup.impl.LookupImpl in project intellij-community by JetBrains.

the class JsonSchemaCrossReferencesTest method checkSchemaCompletion.

private void checkSchemaCompletion(VirtualFile moduleFile, final String fileName) {
    doHighlighting();
    complete();
    assertStringItems("\"one\"", "\"two\"");
    final VirtualFile baseFile = moduleFile.findChild(fileName);
    Assert.assertNotNull(baseFile);
    FileDocumentManager fileDocumentManager = FileDocumentManager.getInstance();
    Document document = fileDocumentManager.getDocument(baseFile);
    Assert.assertNotNull(document);
    String str = "\"enum\": [\"one\", \"two\"]";
    int start = document.getText().indexOf(str);
    Assert.assertTrue(start > 0);
    ApplicationManager.getApplication().runWriteAction(() -> {
        document.replaceString(start, start + str.length(), "\"enum\": [\"one1\", \"two1\"]");
        fileDocumentManager.saveAllDocuments();
    });
    LookupImpl lookup = getActiveLookup();
    if (lookup != null)
        lookup.hide();
    JsonSchemaService.Impl.get(getProject()).reset();
    doHighlighting();
    complete();
    assertStringItems("\"one1\"", "\"two1\"");
    lookup = getActiveLookup();
    if (lookup != null)
        lookup.hide();
    JsonSchemaService.Impl.get(getProject()).reset();
    doHighlighting();
    complete();
    assertStringItems("\"one1\"", "\"two1\"");
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LookupImpl(com.intellij.codeInsight.lookup.impl.LookupImpl) FileDocumentManager(com.intellij.openapi.fileEditor.FileDocumentManager) Document(com.intellij.openapi.editor.Document)

Example 38 with LookupImpl

use of com.intellij.codeInsight.lookup.impl.LookupImpl in project intellij-community by JetBrains.

the class PythonAutoPopupTest method testAutoPopupAfterDotDuringAnotherAutoPopup.

public void testAutoPopupAfterDotDuringAnotherAutoPopup() {
    myFixture.configureByText("a.py", FOO_CLASS + "foo = Foo()\n" + "foo2 = Foo()\n" + "<caret>");
    myTester.typeWithPauses("foo");
    LookupImpl lookup1 = myTester.getLookup();
    assertNotNull(lookup1);
    assertFalse(lookup1.isFocused());
    myTester.typeWithPauses(".");
    LookupImpl lookup2 = myTester.getLookup();
    assertNotSame(lookup1, lookup2);
    assertNotNull(lookup2);
    assertFalse(lookup2.isFocused());
}
Also used : LookupImpl(com.intellij.codeInsight.lookup.impl.LookupImpl)

Example 39 with LookupImpl

use of com.intellij.codeInsight.lookup.impl.LookupImpl in project intellij-plugins by JetBrains.

the class OgnlLiveTemplatesTest method expandLiveTemplate.

private void expandLiveTemplate() {
    new ListTemplatesAction().actionPerformedImpl(myFixture.getProject(), myFixture.getEditor());
    LookupImpl lookup = (LookupImpl) LookupManager.getActiveLookup(myFixture.getEditor());
    assertNotNull(lookup);
    lookup.finishLookup(Lookup.NORMAL_SELECT_CHAR);
}
Also used : LookupImpl(com.intellij.codeInsight.lookup.impl.LookupImpl) ListTemplatesAction(com.intellij.codeInsight.template.impl.actions.ListTemplatesAction)

Aggregations

LookupImpl (com.intellij.codeInsight.lookup.impl.LookupImpl)39 ListTemplatesAction (com.intellij.codeInsight.template.impl.actions.ListTemplatesAction)5 Document (com.intellij.openapi.editor.Document)5 Editor (com.intellij.openapi.editor.Editor)5 Project (com.intellij.openapi.project.Project)5 LookupElement (com.intellij.codeInsight.lookup.LookupElement)4 PlainPrefixMatcher (com.intellij.codeInsight.completion.PlainPrefixMatcher)2 LookupEx (com.intellij.codeInsight.lookup.LookupEx)2 TemplateState (com.intellij.codeInsight.template.impl.TemplateState)2 CodeInsightSettings (com.intellij.codeInsight.CodeInsightSettings)1 CamelHumpMatcher (com.intellij.codeInsight.completion.impl.CamelHumpMatcher)1 CompletionSorterImpl (com.intellij.codeInsight.completion.impl.CompletionSorterImpl)1 Lookup (com.intellij.codeInsight.lookup.Lookup)1 LookupManager (com.intellij.codeInsight.lookup.LookupManager)1 LiveTemplateLookupElement (com.intellij.codeInsight.template.impl.LiveTemplateLookupElement)1 CommandAdapter (com.intellij.openapi.command.CommandAdapter)1 CommandEvent (com.intellij.openapi.command.CommandEvent)1 SelectionModel (com.intellij.openapi.editor.SelectionModel)1 DocCommandGroupId (com.intellij.openapi.editor.actionSystem.DocCommandGroupId)1 EditorEx (com.intellij.openapi.editor.ex.EditorEx)1