From 3a4efe9c979e6927d0d8271882a56d6dced14cae Mon Sep 17 00:00:00 2001 From: BoykoAlex Date: Thu, 17 Oct 2019 19:03:49 -0400 Subject: [PATCH] LS sends Location for Theia client instead of LocationLink --- .../languageserver/util/SimpleTextDocumentService.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/util/SimpleTextDocumentService.java b/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/util/SimpleTextDocumentService.java index 212d0ec1b..4f6f86092 100644 --- a/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/util/SimpleTextDocumentService.java +++ b/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/util/SimpleTextDocumentService.java @@ -363,10 +363,16 @@ public class SimpleTextDocumentService implements TextDocumentService, DocumentE return async.invoke(() -> { List locations = h.handle(position); if (locations==null) { - // vscode client does not like to recieve null result. See: https://github.com/spring-projects/sts4/issues/309 + // vscode client does not like to receive null result. See: https://github.com/spring-projects/sts4/issues/309 locations = ImmutableList.of(); } - return Either.forRight(locations); + // Workaround for https://github.com/eclipse-theia/theia/issues/6414 + // Theia does not support LocationLink yet + if (LspClient.currentClient() == LspClient.Client.THEIA) { + return Either.forLeft(locations.stream().map(link -> new Location(link.getTargetUri(), link.getTargetRange())).collect(Collectors.toList())); + } else { + return Either.forRight(locations); + } }); } return CompletableFuture.completedFuture(Either.forLeft(ImmutableList.of()));