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:
+28
@@ -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;
|
||||
}
|
||||
}
|
||||
+13
@@ -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());
|
||||
}
|
||||
}
|
||||
+1
@@ -16,6 +16,7 @@ public record BaselineServerDescription(
|
||||
boolean workspaceSymbolsSupported,
|
||||
boolean renameSupported,
|
||||
boolean codeActionsSupported,
|
||||
boolean documentLinksSupported,
|
||||
List<String> semanticTokenTypes,
|
||||
List<BaselineSemanticHostProjection> semanticHostProjections,
|
||||
List<BaselineVisualTheme> visualThemes,
|
||||
|
||||
Reference in New Issue
Block a user