Search in sources :

Example 1 with TextOfLineResult

use of org.eclipse.xtext.ide.tests.testlanguage.ide.TestLangLSPExtension.TextOfLineResult in project xtext-core by eclipse.

the class LspExtensionTest method testExtension.

@Test
public void testExtension() throws Exception {
    String fileURI = writeFile("mydoc.testlang", "");
    initialize();
    TestLangLSPExtension ext = ServiceEndpoints.toServiceObject(languageServer, TestLangLSPExtension.class);
    DidOpenTextDocumentParams didOpenTextDocumentParams = new DidOpenTextDocumentParams();
    String text = "foo bar" + System.lineSeparator() + "baz test" + System.lineSeparator() + "	bla blubb";
    didOpenTextDocumentParams.setTextDocument(new TextDocumentItem(fileURI, "testlang", 0, text));
    languageServer.didOpen(didOpenTextDocumentParams);
    TextOfLineParam textOfLineParam = new TextOfLineParam();
    textOfLineParam.uri = fileURI;
    textOfLineParam.line = 1;
    TextOfLineResult result = ext.getTextOfLine(textOfLineParam).get();
    Assert.assertEquals("baz test", result.text);
    Assert.assertEquals(2, IterableExtensions.size(Iterables.filter(Iterables.transform(notifications, n -> n.getValue()), TestLangLSPExtension.BuildNotification.class)));
}
Also used : List(java.util.List) TextDocumentItem(org.eclipse.lsp4j.TextDocumentItem) Iterables(com.google.common.collect.Iterables) IterableExtensions(org.eclipse.xtext.xbase.lib.IterableExtensions) Lists(com.google.common.collect.Lists) TestLangLSPExtension(org.eclipse.xtext.ide.tests.testlanguage.ide.TestLangLSPExtension) DidOpenTextDocumentParams(org.eclipse.lsp4j.DidOpenTextDocumentParams) ServiceEndpoints(org.eclipse.lsp4j.jsonrpc.services.ServiceEndpoints) Test(org.junit.Test) TextOfLineParam(org.eclipse.xtext.ide.tests.testlanguage.ide.TestLangLSPExtension.TextOfLineParam) Assert(org.junit.Assert) TextOfLineResult(org.eclipse.xtext.ide.tests.testlanguage.ide.TestLangLSPExtension.TextOfLineResult) TextDocumentItem(org.eclipse.lsp4j.TextDocumentItem) DidOpenTextDocumentParams(org.eclipse.lsp4j.DidOpenTextDocumentParams) TestLangLSPExtension(org.eclipse.xtext.ide.tests.testlanguage.ide.TestLangLSPExtension) TextOfLineResult(org.eclipse.xtext.ide.tests.testlanguage.ide.TestLangLSPExtension.TextOfLineResult) TextOfLineParam(org.eclipse.xtext.ide.tests.testlanguage.ide.TestLangLSPExtension.TextOfLineParam) Test(org.junit.Test)

Aggregations

Iterables (com.google.common.collect.Iterables)1 Lists (com.google.common.collect.Lists)1 List (java.util.List)1 DidOpenTextDocumentParams (org.eclipse.lsp4j.DidOpenTextDocumentParams)1 TextDocumentItem (org.eclipse.lsp4j.TextDocumentItem)1 ServiceEndpoints (org.eclipse.lsp4j.jsonrpc.services.ServiceEndpoints)1 TestLangLSPExtension (org.eclipse.xtext.ide.tests.testlanguage.ide.TestLangLSPExtension)1 TextOfLineParam (org.eclipse.xtext.ide.tests.testlanguage.ide.TestLangLSPExtension.TextOfLineParam)1 TextOfLineResult (org.eclipse.xtext.ide.tests.testlanguage.ide.TestLangLSPExtension.TextOfLineResult)1 IterableExtensions (org.eclipse.xtext.xbase.lib.IterableExtensions)1 Assert (org.junit.Assert)1 Test (org.junit.Test)1