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,20 @@
package p.studio.compiler.services;
import java.nio.file.Path;
import java.util.Objects;
public record FrontendDocumentLink(
Path path,
int startOffset,
int endOffset) {
public FrontendDocumentLink {
path = Objects.requireNonNull(path, "path").toAbsolutePath().normalize();
if (startOffset < 0) {
throw new IllegalArgumentException("startOffset must not be negative");
}
if (endOffset < startOffset) {
throw new IllegalArgumentException("endOffset must not be before startOffset");
}
}
}
@@ -139,6 +139,20 @@ public interface FrontendLanguageService {
return rename(request, offset, newName);
}
default boolean documentLinksSupported() {
return false;
}
default List<FrontendDocumentLink> documentLinks(final FrontendDocumentRequest request) {
return List.of();
}
default List<FrontendDocumentLink> documentLinks(
final FrontendDocumentRequest request,
final FrontendEditorialContext editorialContext) {
return documentLinks(request);
}
default boolean codeActionsSupported() {
return false;
}
@@ -30,6 +30,9 @@ class FrontendLanguageServiceTest {
assertTrue(service.prepareRename(request, 0).isEmpty());
assertEquals(FrontendRenameResult.Status.UNSUPPORTED, service.rename(request, 0, "renamed").status());
assertTrue(service.rename(request, 0, "renamed").edits().isEmpty());
assertFalse(service.documentLinksSupported());
assertTrue(service.documentLinks(request).isEmpty());
assertTrue(service.documentLinks(request, null).isEmpty());
assertFalse(service.codeActionsSupported());
assertTrue(service.codeActions(request).isEmpty());
assertTrue(service.codeActions(request, null).isEmpty());