Search in sources :

Example 1 with LocationLink

use of org.eclipse.lsp4j.LocationLink 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

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