implements PLN-0137 (2/7) document-links

Advertise document links only when the frontend supports them.
A link covers the ModuleRef span when module assembly already
bound that module to a regular file. Virtual stdlib and unresolved
modules produce no link.
This commit is contained in:
2026-09-22 08:34:13 +01:00
parent 099857b636
commit 3320f222bb
18 changed files with 489 additions and 2 deletions
@@ -0,0 +1,28 @@
package p.studio.lsp.messages;
import java.util.Objects;
public record BaselineDocumentLink(
String targetUri,
int startLine,
int startCharacter,
int endLine,
int endCharacter) {
public BaselineDocumentLink {
targetUri = requireText(targetUri, "targetUri");
if (startLine < 0 || startCharacter < 0 || endLine < 0 || endCharacter < 0) {
throw new IllegalArgumentException("document link range coordinates must not be negative");
}
}
private static String requireText(
final String value,
final String field) {
final String candidate = Objects.requireNonNull(value, field).trim();
if (candidate.isEmpty()) {
throw new IllegalArgumentException(field + " must not be blank");
}
return candidate;
}
}
@@ -0,0 +1,13 @@
package p.studio.lsp.messages;
import java.util.List;
public record BaselineDocumentLinks(List<BaselineDocumentLink> links) {
public BaselineDocumentLinks {
links = links == null ? List.of() : List.copyOf(links);
}
public static BaselineDocumentLinks empty() {
return new BaselineDocumentLinks(List.of());
}
}
@@ -16,6 +16,7 @@ public record BaselineServerDescription(
boolean workspaceSymbolsSupported,
boolean renameSupported,
boolean codeActionsSupported,
boolean documentLinksSupported,
List<String> semanticTokenTypes,
List<BaselineSemanticHostProjection> semanticHostProjections,
List<BaselineVisualTheme> visualThemes,