Search in sources :

Example 1 with TextDocumentPositionParams

use of org.eclipse.lsp4j.TextDocumentPositionParams in project vscode-nextgenas by BowlerHatLLC.

the class ActionScriptTextDocumentService method getEmbeddedActionScriptNodeInMXMLTag.

private IASNode getEmbeddedActionScriptNodeInMXMLTag(IMXMLTagData tag, int offset, TextDocumentIdentifier textDocument, Position position) {
    TextDocumentPositionParams textDocumentPosition = new TextDocumentPositionParams();
    textDocumentPosition.setTextDocument(textDocument);
    textDocumentPosition.setPosition(position);
    return getEmbeddedActionScriptNodeInMXMLTag(tag, offset, textDocumentPosition);
}
Also used : TextDocumentPositionParams(org.eclipse.lsp4j.TextDocumentPositionParams)

Example 2 with TextDocumentPositionParams

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

the class ServerTest method testMissingInitialize.

@Test
public void testMissingInitialize() {
    try {
        try {
            TextDocumentPositionParams _textDocumentPositionParams = new TextDocumentPositionParams();
            final Procedure1<TextDocumentPositionParams> _function = (TextDocumentPositionParams it) -> {
                TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier();
                final Procedure1<TextDocumentIdentifier> _function_1 = (TextDocumentIdentifier it_1) -> {
                    it_1.setUri("file:/home/test/workspace/mydoc.testlang");
                };
                TextDocumentIdentifier _doubleArrow = ObjectExtensions.<TextDocumentIdentifier>operator_doubleArrow(_textDocumentIdentifier, _function_1);
                it.setTextDocument(_doubleArrow);
            };
            TextDocumentPositionParams _doubleArrow = ObjectExtensions.<TextDocumentPositionParams>operator_doubleArrow(_textDocumentPositionParams, _function);
            this.languageServer.definition(_doubleArrow).get();
            Assert.fail("Expected a ResponseErrorException");
        } catch (final Throwable _t) {
            if (_t instanceof ExecutionException) {
                final ExecutionException exception = (ExecutionException) _t;
                Throwable _cause = exception.getCause();
                Assert.assertEquals(ResponseErrorCode.serverNotInitialized.getValue(), ((ResponseErrorException) _cause).getResponseError().getCode());
            } else {
                throw Exceptions.sneakyThrow(_t);
            }
        }
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : TextDocumentIdentifier(org.eclipse.lsp4j.TextDocumentIdentifier) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) TextDocumentPositionParams(org.eclipse.lsp4j.TextDocumentPositionParams) ExecutionException(java.util.concurrent.ExecutionException) Test(org.junit.Test) AbstractTestLangLanguageServerTest(org.eclipse.xtext.ide.tests.server.AbstractTestLangLanguageServerTest)

Example 3 with TextDocumentPositionParams

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

the class UnknownProjectConfigTest method checkCompletion.

protected void checkCompletion(final String uri) {
    try {
        TextDocumentPositionParams _textDocumentPositionParams = new TextDocumentPositionParams();
        final Procedure1<TextDocumentPositionParams> _function = (TextDocumentPositionParams it) -> {
            TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(uri);
            it.setTextDocument(_textDocumentIdentifier);
            Position _position = new Position(0, 10);
            it.setPosition(_position);
        };
        TextDocumentPositionParams _doubleArrow = ObjectExtensions.<TextDocumentPositionParams>operator_doubleArrow(_textDocumentPositionParams, _function);
        final CompletableFuture<Either<List<CompletionItem>, CompletionList>> completionItems = this.languageServer.completion(_doubleArrow);
        final Either<List<CompletionItem>, CompletionList> result = completionItems.get();
        List<CompletionItem> _xifexpression = null;
        boolean _isLeft = result.isLeft();
        if (_isLeft) {
            _xifexpression = result.getLeft();
        } else {
            _xifexpression = result.getRight().getItems();
        }
        final List<CompletionItem> items = _xifexpression;
        final String actualCompletionItems = this.toExpectation(items);
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("Foo (TypeDeclaration) -> Foo [[0, 10] .. [0, 10]]");
        _builder.newLine();
        _builder.append("boolean -> boolean [[0, 10] .. [0, 10]]");
        _builder.newLine();
        _builder.append("int -> int [[0, 10] .. [0, 10]]");
        _builder.newLine();
        _builder.append("op -> op [[0, 10] .. [0, 10]]");
        _builder.newLine();
        _builder.append("string -> string [[0, 10] .. [0, 10]]");
        _builder.newLine();
        _builder.append("void -> void [[0, 10] .. [0, 10]]");
        _builder.newLine();
        _builder.append("} -> } [[0, 10] .. [0, 10]]");
        _builder.newLine();
        _builder.append("{ -> { [[0, 9] .. [0, 10]]");
        _builder.newLine();
        final String expectedCompletionItems = _builder.toString();
        this.assertEquals(expectedCompletionItems, actualCompletionItems);
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : CompletionList(org.eclipse.lsp4j.CompletionList) TextDocumentIdentifier(org.eclipse.lsp4j.TextDocumentIdentifier) Position(org.eclipse.lsp4j.Position) CompletionItem(org.eclipse.lsp4j.CompletionItem) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Either(org.eclipse.lsp4j.jsonrpc.messages.Either) List(java.util.List) CompletionList(org.eclipse.lsp4j.CompletionList) TextDocumentPositionParams(org.eclipse.lsp4j.TextDocumentPositionParams)

Example 4 with TextDocumentPositionParams

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

the class AbstractLanguageServerTest method testSignatureHelp.

protected void testSignatureHelp(final Procedure1<? super SignatureHelpConfiguration> configurator) {
    try {
        @Extension final SignatureHelpConfiguration configuration = new SignatureHelpConfiguration();
        configuration.setFilePath(("MyModel." + this.fileExtension));
        configurator.apply(configuration);
        final String fileUri = this.initializeContext(configuration).getUri();
        TextDocumentPositionParams _textDocumentPositionParams = new TextDocumentPositionParams();
        final Procedure1<TextDocumentPositionParams> _function = (TextDocumentPositionParams it) -> {
            TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(fileUri);
            it.setTextDocument(_textDocumentIdentifier);
            int _line = configuration.getLine();
            int _column = configuration.getColumn();
            Position _position = new Position(_line, _column);
            it.setPosition(_position);
        };
        TextDocumentPositionParams _doubleArrow = ObjectExtensions.<TextDocumentPositionParams>operator_doubleArrow(_textDocumentPositionParams, _function);
        final CompletableFuture<SignatureHelp> signatureHelpFuture = this.languageServer.signatureHelp(_doubleArrow);
        final SignatureHelp signatureHelp = signatureHelpFuture.get();
        Procedure1<? super SignatureHelp> _assertSignatureHelp = configuration.getAssertSignatureHelp();
        boolean _tripleNotEquals = (_assertSignatureHelp != null);
        if (_tripleNotEquals) {
            configuration.getAssertSignatureHelp().apply(signatureHelp);
        } else {
            final String actualSignatureHelp = this.toExpectation(signatureHelp);
            this.assertEquals(configuration.getExpectedSignatureHelp().trim(), actualSignatureHelp.trim());
        }
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : Extension(org.eclipse.xtext.xbase.lib.Extension) TextDocumentIdentifier(org.eclipse.lsp4j.TextDocumentIdentifier) Position(org.eclipse.lsp4j.Position) SignatureHelpConfiguration(org.eclipse.xtext.testing.SignatureHelpConfiguration) SignatureHelp(org.eclipse.lsp4j.SignatureHelp) TextDocumentPositionParams(org.eclipse.lsp4j.TextDocumentPositionParams)

Example 5 with TextDocumentPositionParams

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

the class AbstractLanguageServerTest method testDocumentHighlight.

protected void testDocumentHighlight(final Procedure1<? super DocumentHighlightConfiguration> configurator) {
    try {
        DocumentHighlightConfiguration _documentHighlightConfiguration = new DocumentHighlightConfiguration();
        final Procedure1<DocumentHighlightConfiguration> _function = (DocumentHighlightConfiguration it) -> {
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("MyModel.");
            _builder.append(this.fileExtension);
            it.setFilePath(_builder.toString());
        };
        @Extension final DocumentHighlightConfiguration configuration = ObjectExtensions.<DocumentHighlightConfiguration>operator_doubleArrow(_documentHighlightConfiguration, _function);
        configurator.apply(configuration);
        final String fileUri = this.initializeContext(configuration).getUri();
        TextDocumentPositionParams _textDocumentPositionParams = new TextDocumentPositionParams();
        final Procedure1<TextDocumentPositionParams> _function_1 = (TextDocumentPositionParams it) -> {
            TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(fileUri);
            it.setTextDocument(_textDocumentIdentifier);
            int _line = configuration.getLine();
            int _column = configuration.getColumn();
            Position _position = new Position(_line, _column);
            it.setPosition(_position);
        };
        TextDocumentPositionParams _doubleArrow = ObjectExtensions.<TextDocumentPositionParams>operator_doubleArrow(_textDocumentPositionParams, _function_1);
        final CompletableFuture<List<? extends DocumentHighlight>> highlights = this.languageServer.documentHighlight(_doubleArrow);
        final Function1<DocumentHighlight, String> _function_2 = (DocumentHighlight it) -> {
            return this.toExpectation(it);
        };
        final String actualDocumentHighlight = IterableExtensions.join(ListExtensions.map(highlights.get(), _function_2), " | ");
        this.assertEquals(configuration.getExpectedDocumentHighlight(), actualDocumentHighlight);
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : DocumentHighlight(org.eclipse.lsp4j.DocumentHighlight) TextDocumentIdentifier(org.eclipse.lsp4j.TextDocumentIdentifier) Position(org.eclipse.lsp4j.Position) Extension(org.eclipse.xtext.xbase.lib.Extension) DocumentHighlightConfiguration(org.eclipse.xtext.testing.DocumentHighlightConfiguration) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) List(java.util.List) CompletionList(org.eclipse.lsp4j.CompletionList) TextDocumentPositionParams(org.eclipse.lsp4j.TextDocumentPositionParams)

Aggregations

TextDocumentPositionParams (org.eclipse.lsp4j.TextDocumentPositionParams)8 TextDocumentIdentifier (org.eclipse.lsp4j.TextDocumentIdentifier)7 Position (org.eclipse.lsp4j.Position)6 Extension (org.eclipse.xtext.xbase.lib.Extension)5 List (java.util.List)4 CompletionList (org.eclipse.lsp4j.CompletionList)4 CompletionItem (org.eclipse.lsp4j.CompletionItem)2 Either (org.eclipse.lsp4j.jsonrpc.messages.Either)2 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)2 ExecutionException (java.util.concurrent.ExecutionException)1 DocumentHighlight (org.eclipse.lsp4j.DocumentHighlight)1 Hover (org.eclipse.lsp4j.Hover)1 Location (org.eclipse.lsp4j.Location)1 SignatureHelp (org.eclipse.lsp4j.SignatureHelp)1 AbstractTestLangLanguageServerTest (org.eclipse.xtext.ide.tests.server.AbstractTestLangLanguageServerTest)1 DefinitionTestConfiguration (org.eclipse.xtext.testing.DefinitionTestConfiguration)1 DocumentHighlightConfiguration (org.eclipse.xtext.testing.DocumentHighlightConfiguration)1 HoverTestConfiguration (org.eclipse.xtext.testing.HoverTestConfiguration)1 SignatureHelpConfiguration (org.eclipse.xtext.testing.SignatureHelpConfiguration)1 TestCompletionConfiguration (org.eclipse.xtext.testing.TestCompletionConfiguration)1