Search in sources :

Example 6 with TextDocumentItem

use of org.eclipse.lsp4j.TextDocumentItem in project xtext-core by eclipse.

the class UnknownProjectConfigTest method testCompletionWithFileScheme_01.

@Test
public void testCompletionWithFileScheme_01() {
    final Procedure1<InitializeParams> _function = (InitializeParams it) -> {
        it.setRootUri(null);
    };
    this.initialize(_function);
    final String fileUri = "file:/home/test/workspace/mydoc.testlang";
    DidOpenTextDocumentParams _didOpenTextDocumentParams = new DidOpenTextDocumentParams();
    final Procedure1<DidOpenTextDocumentParams> _function_1 = (DidOpenTextDocumentParams it) -> {
        TextDocumentItem _textDocumentItem = new TextDocumentItem();
        final Procedure1<TextDocumentItem> _function_2 = (TextDocumentItem it_1) -> {
            it_1.setUri(fileUri);
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("type Foo {}");
            _builder.newLine();
            it_1.setText(_builder.toString());
        };
        TextDocumentItem _doubleArrow = ObjectExtensions.<TextDocumentItem>operator_doubleArrow(_textDocumentItem, _function_2);
        it.setTextDocument(_doubleArrow);
    };
    DidOpenTextDocumentParams _doubleArrow = ObjectExtensions.<DidOpenTextDocumentParams>operator_doubleArrow(_didOpenTextDocumentParams, _function_1);
    this.languageServer.didOpen(_doubleArrow);
    this.checkCompletion(fileUri);
}
Also used : TextDocumentItem(org.eclipse.lsp4j.TextDocumentItem) DidOpenTextDocumentParams(org.eclipse.lsp4j.DidOpenTextDocumentParams) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) InitializeParams(org.eclipse.lsp4j.InitializeParams) Test(org.junit.Test) AbstractTestLangLanguageServerTest(org.eclipse.xtext.ide.tests.server.AbstractTestLangLanguageServerTest)

Example 7 with TextDocumentItem

use of org.eclipse.lsp4j.TextDocumentItem in project xtext-core by eclipse.

the class LspExtensionTest method testExtension.

@Test
public void testExtension() {
    try {
        final String fileURI = this.writeFile("mydoc.testlang", "");
        this.initialize();
        final TestLangLSPExtension ext = ServiceEndpoints.<TestLangLSPExtension>toServiceObject(this.languageServer, TestLangLSPExtension.class);
        DidOpenTextDocumentParams _didOpenTextDocumentParams = new DidOpenTextDocumentParams();
        final Procedure1<DidOpenTextDocumentParams> _function = (DidOpenTextDocumentParams it) -> {
            TextDocumentItem _textDocumentItem = new TextDocumentItem();
            final Procedure1<TextDocumentItem> _function_1 = (TextDocumentItem it_1) -> {
                it_1.setUri(fileURI);
                StringConcatenation _builder = new StringConcatenation();
                _builder.append("foo bar");
                _builder.newLine();
                _builder.append("baz test");
                _builder.newLine();
                _builder.append("\t");
                _builder.append("bla blubb");
                _builder.newLine();
                it_1.setText(_builder.toString());
            };
            TextDocumentItem _doubleArrow = ObjectExtensions.<TextDocumentItem>operator_doubleArrow(_textDocumentItem, _function_1);
            it.setTextDocument(_doubleArrow);
        };
        DidOpenTextDocumentParams _doubleArrow = ObjectExtensions.<DidOpenTextDocumentParams>operator_doubleArrow(_didOpenTextDocumentParams, _function);
        this.languageServer.didOpen(_doubleArrow);
        TestLangLSPExtension.TextOfLineParam _textOfLineParam = new TestLangLSPExtension.TextOfLineParam();
        final Procedure1<TestLangLSPExtension.TextOfLineParam> _function_1 = (TestLangLSPExtension.TextOfLineParam it) -> {
            it.uri = fileURI;
            it.line = 1;
        };
        TestLangLSPExtension.TextOfLineParam _doubleArrow_1 = ObjectExtensions.<TestLangLSPExtension.TextOfLineParam>operator_doubleArrow(_textOfLineParam, _function_1);
        final TestLangLSPExtension.TextOfLineResult result = ext.getTextOfLine(_doubleArrow_1).get();
        Assert.assertEquals("baz test", result.text);
        final Function1<Pair<String, Object>, Object> _function_2 = (Pair<String, Object> it) -> {
            return it.getValue();
        };
        Assert.assertEquals(2, IterableExtensions.size(Iterables.<TestLangLSPExtension.BuildNotification>filter(ListExtensions.<Pair<String, Object>, Object>map(this.notifications, _function_2), TestLangLSPExtension.BuildNotification.class)));
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : TextDocumentItem(org.eclipse.lsp4j.TextDocumentItem) DidOpenTextDocumentParams(org.eclipse.lsp4j.DidOpenTextDocumentParams) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) TestLangLSPExtension(org.eclipse.xtext.ide.tests.testlanguage.ide.TestLangLSPExtension) Pair(org.eclipse.xtext.xbase.lib.Pair) Test(org.junit.Test) AbstractTestLangLanguageServerTest(org.eclipse.xtext.ide.tests.server.AbstractTestLangLanguageServerTest)

Aggregations

TextDocumentItem (org.eclipse.lsp4j.TextDocumentItem)7 DidOpenTextDocumentParams (org.eclipse.lsp4j.DidOpenTextDocumentParams)6 Procedure1 (org.eclipse.xtext.xbase.lib.Procedures.Procedure1)6 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)5 AbstractTestLangLanguageServerTest (org.eclipse.xtext.ide.tests.server.AbstractTestLangLanguageServerTest)5 Test (org.junit.Test)5 InitializeParams (org.eclipse.lsp4j.InitializeParams)2 Path (java.nio.file.Path)1 TestLangLSPExtension (org.eclipse.xtext.ide.tests.testlanguage.ide.TestLangLSPExtension)1 Pair (org.eclipse.xtext.xbase.lib.Pair)1