Search in sources :

Example 1 with DefinitionParams

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

the class ServerTest method testMissingInitialize.

@Test
public void testMissingInitialize() throws Exception {
    try {
        DefinitionParams definitionParams = new DefinitionParams();
        definitionParams.setTextDocument(new TextDocumentIdentifier("file:/home/test/workspace/mydoc.testlang"));
        languageServer.definition(definitionParams).get();
        Assert.fail("Expected a ResponseErrorException");
    } catch (ExecutionException exception) {
        Assert.assertEquals(ResponseErrorCode.serverNotInitialized.getValue(), ((ResponseErrorException) exception.getCause()).getResponseError().getCode());
    }
}
Also used : TextDocumentIdentifier(org.eclipse.lsp4j.TextDocumentIdentifier) ExecutionException(java.util.concurrent.ExecutionException) DefinitionParams(org.eclipse.lsp4j.DefinitionParams) Test(org.junit.Test)

Example 2 with DefinitionParams

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

the class AbstractLanguageServerTest method testDefinition.

protected void testDefinition(final Procedure1<? super DefinitionTestConfiguration> configurator) {
    try {
        @Extension final DefinitionTestConfiguration configuration = new DefinitionTestConfiguration();
        configuration.setFilePath(("MyModel." + this.fileExtension));
        configurator.apply(configuration);
        final String fileUri = this.initializeContext(configuration).getUri();
        DefinitionParams _definitionParams = new DefinitionParams();
        final Procedure1<DefinitionParams> _function = (DefinitionParams 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);
        };
        DefinitionParams _doubleArrow = ObjectExtensions.<DefinitionParams>operator_doubleArrow(_definitionParams, _function);
        final CompletableFuture<Either<List<? extends Location>, List<? extends LocationLink>>> definitionsFuture = this.languageServer.definition(_doubleArrow);
        final Either<List<? extends Location>, List<? extends LocationLink>> definitions = definitionsFuture.get();
        Procedure1<? super List<? extends Location>> _assertDefinitions = configuration.getAssertDefinitions();
        boolean _tripleNotEquals = (_assertDefinitions != null);
        if (_tripleNotEquals) {
            configuration.getAssertDefinitions().apply(definitions.getLeft());
        } else {
            final String actualDefinitions = this.toExpectation(definitions);
            this.assertEquals(configuration.getExpectedDefinitions(), actualDefinitions);
        }
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : LocationLink(org.eclipse.lsp4j.LocationLink) VersionedTextDocumentIdentifier(org.eclipse.lsp4j.VersionedTextDocumentIdentifier) TextDocumentIdentifier(org.eclipse.lsp4j.TextDocumentIdentifier) Position(org.eclipse.lsp4j.Position) Extension(org.eclipse.xtext.xbase.lib.Extension) Either(org.eclipse.lsp4j.jsonrpc.messages.Either) List(java.util.List) CompletionList(org.eclipse.lsp4j.CompletionList) DefinitionParams(org.eclipse.lsp4j.DefinitionParams) Location(org.eclipse.lsp4j.Location)

Aggregations

DefinitionParams (org.eclipse.lsp4j.DefinitionParams)2 TextDocumentIdentifier (org.eclipse.lsp4j.TextDocumentIdentifier)2 List (java.util.List)1 ExecutionException (java.util.concurrent.ExecutionException)1 CompletionList (org.eclipse.lsp4j.CompletionList)1 Location (org.eclipse.lsp4j.Location)1 LocationLink (org.eclipse.lsp4j.LocationLink)1 Position (org.eclipse.lsp4j.Position)1 VersionedTextDocumentIdentifier (org.eclipse.lsp4j.VersionedTextDocumentIdentifier)1 Either (org.eclipse.lsp4j.jsonrpc.messages.Either)1 Extension (org.eclipse.xtext.xbase.lib.Extension)1 Test (org.junit.Test)1