Data query parameter go to definition, doc highlights and inlay hints

This commit is contained in:
aboyko
2024-08-23 22:02:24 -04:00
parent 42eca4fed9
commit 00636085ca
34 changed files with 1056 additions and 280 deletions

View File

@@ -31,7 +31,6 @@ import org.eclipse.lsp4j.DocumentSymbolParams;
import org.eclipse.lsp4j.Hover;
import org.eclipse.lsp4j.HoverParams;
import org.eclipse.lsp4j.InlayHint;
import org.eclipse.lsp4j.InlayHintParams;
import org.eclipse.lsp4j.Range;
import org.eclipse.lsp4j.SemanticTokensLegend;
import org.eclipse.lsp4j.SemanticTokensWithRegistrationOptions;
@@ -175,15 +174,14 @@ public class CompositeLanguageServerComponents implements LanguageServerComponen
this.inlayHintHandler = new InlayHintHandler() {
@Override
public List<InlayHint> handle(CancelChecker token, InlayHintParams params) {
TextDocument doc = server.getTextDocumentService().getLatestSnapshot(params.getTextDocument().getUri());
public List<InlayHint> handle(TextDocument doc, Range r, CancelChecker token) {
LanguageId language = doc.getLanguageId();
List<LanguageServerComponents> subComponents = componentsByLanguageId.get(language);
if (subComponents != null) {
return subComponents.stream()
.map(sc -> sc.getInlayHintHandler())
.filter(h -> h.isPresent())
.flatMap(h -> h.get().handle(token, params).stream())
.flatMap(h -> h.get().handle(doc, r, token).stream())
.collect(Collectors.toList());
}
// No applicable subEngine...

View File

@@ -13,7 +13,12 @@ package org.springframework.ide.vscode.commons.languageserver.semantic.tokens;
import java.util.Arrays;
import java.util.Objects;
public record SemanticTokenData(int start, int end, String type, String[] modifiers) implements Comparable<SemanticTokenData>{
public record SemanticTokenData(
int start,
int end,
String type,
String[] modifiers
) implements Comparable<SemanticTokenData> {
@Override
public int compareTo(SemanticTokenData o) {

View File

@@ -13,11 +13,12 @@ package org.springframework.ide.vscode.commons.languageserver.util;
import java.util.List;
import org.eclipse.lsp4j.InlayHint;
import org.eclipse.lsp4j.InlayHintParams;
import org.eclipse.lsp4j.Range;
import org.eclipse.lsp4j.jsonrpc.CancelChecker;
import org.springframework.ide.vscode.commons.util.text.TextDocument;
public interface InlayHintHandler {
List<InlayHint> handle(CancelChecker token, InlayHintParams params);
List<InlayHint> handle(TextDocument doc, Range range, CancelChecker cancelChecker);
}

View File

@@ -581,9 +581,12 @@ public class SimpleTextDocumentService implements TextDocumentService, DocumentE
InlayHintHandler handler = this.inlayHintHandler;
if (handler != null) {
return CompletableFutures.computeAsync(messageWorkerThreadPool, cancelToken -> {
return handler.handle(cancelToken, params);
});
TextDocument doc = getLatestSnapshot(params.getTextDocument().getUri());
if (doc != null) {
return CompletableFutures.computeAsync(messageWorkerThreadPool, cancelToken -> {
return handler.handle(doc, params.getRange(), cancelToken);
});
}
}
return CompletableFuture.completedFuture(Collections.emptyList());
}