implements PLN-0133
Intrepid/Prometeu/Studio/pipeline/pr-master Build started...
JaCoCo Coverage #### Project Overview No changes detected, that affect the code coverage. * Line Coverage: 62.84% (18504/29445) * Branch Coverage: 53.33% (7215/13528) * Lines of Code: 29445 * Cyclomatic Complexity: 11850 #### Quality Gates Summary Output truncated.
Test / Build skipped: 15, passed: 669
Intrepid/Prometeu/Studio/pipeline/head This commit looks good

Add PBS document symbols as an AST-backed hierarchical outline of
the open .pbs file on FrontendLanguageService. Recovered syntax is
enough; unnamed InvalidDecl is omitted; barrels, imports, locals,
and compile-only frontends stay empty. Advertise documentSymbolProvider
with hierarchical DocumentSymbol.

Housekeep DSC-0041 with LSN-0070.
This commit is contained in:
2026-09-21 10:16:14 +01:00
parent 331ad752d1
commit 5d3d48e802
25 changed files with 1183 additions and 66 deletions
@@ -0,0 +1,44 @@
package p.studio.compiler.services;
import java.util.List;
import java.util.Objects;
public record FrontendDocumentSymbol(
String name,
FrontendSymbolKind kind,
String detail,
int rangeStart,
int rangeEnd,
int selectionStart,
int selectionEnd,
List<FrontendDocumentSymbol> children) {
public FrontendDocumentSymbol {
name = requireText(name, "name");
kind = Objects.requireNonNull(kind, "kind");
detail = detail == null ? "" : detail.trim();
if (rangeStart < 0) {
throw new IllegalArgumentException("rangeStart must not be negative");
}
if (rangeEnd < rangeStart) {
throw new IllegalArgumentException("rangeEnd must not be before rangeStart");
}
if (selectionStart < 0) {
throw new IllegalArgumentException("selectionStart must not be negative");
}
if (selectionEnd < selectionStart) {
throw new IllegalArgumentException("selectionEnd must not be before selectionStart");
}
children = children == null ? List.of() : List.copyOf(children);
}
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;
}
}
@@ -85,4 +85,14 @@ public interface FrontendLanguageService {
final int offset) {
return references(request, offset);
}
default List<FrontendDocumentSymbol> documentSymbols(final FrontendDocumentRequest request) {
return List.of();
}
default List<FrontendDocumentSymbol> documentSymbols(
final FrontendDocumentRequest request,
final FrontendEditorialContext editorialContext) {
return documentSymbols(request);
}
}
@@ -24,6 +24,70 @@ class FrontendLanguageServiceTest {
assertEquals(FrontendSignatureHelp.empty(), service.signatureHelp(request, 0));
assertTrue(service.definition(request, 0).isEmpty());
assertTrue(service.references(request, 0).isEmpty());
assertTrue(service.documentSymbols(request).isEmpty());
}
@Test
void documentSymbolRejectsBlankNameAndInvertedRangesAndCopiesChildren() {
final var child = new FrontendDocumentSymbol(
"x",
FrontendSymbolKind.FIELD,
"int",
10,
16,
10,
16,
List.of());
final var symbol = new FrontendDocumentSymbol(
" Point ",
FrontendSymbolKind.STRUCT,
" ",
0,
20,
8,
13,
List.of(child));
assertEquals("Point", symbol.name());
assertEquals("", symbol.detail());
assertEquals(1, symbol.children().size());
assertEquals("x", symbol.children().getFirst().name());
assertThrows(UnsupportedOperationException.class, () -> symbol.children().add(child));
assertThrows(IllegalArgumentException.class, () -> new FrontendDocumentSymbol(
" ",
FrontendSymbolKind.FUNCTION,
"",
0,
1,
0,
1,
List.of()));
assertThrows(IllegalArgumentException.class, () -> new FrontendDocumentSymbol(
"fn",
FrontendSymbolKind.FUNCTION,
"",
-1,
1,
0,
1,
List.of()));
assertThrows(IllegalArgumentException.class, () -> new FrontendDocumentSymbol(
"fn",
FrontendSymbolKind.FUNCTION,
"",
5,
4,
0,
1,
List.of()));
assertThrows(IllegalArgumentException.class, () -> new FrontendDocumentSymbol(
"fn",
FrontendSymbolKind.FUNCTION,
"",
0,
1,
3,
2,
List.of()));
}
@Test