implements PLN-0100

This commit is contained in:
2026-07-15 07:18:19 +01:00
parent e7647165bc
commit 63215ac02f
11 changed files with 525 additions and 9 deletions
@@ -377,6 +377,44 @@ class PbsParserTest {
assertTrue(((PbsAst.AttributeDocTextBlockValue) signatureDoc).value().endsWith("\"\"\""));
}
@Test
void shouldPreserveDocumentationAttributesOnStructAndServiceMethods() {
final var source = """
declare struct Sprite() {
[Doc(markdown = \"""
Draws this sprite.
\""")]
fn draw() -> void {}
}
[Doc(markdown = \"""
Provides drawing commands.
\""")]
declare service Gfx {
[Doc(markdown = \"""
Clears the screen.
\""")]
fn clear() -> void {}
}
""";
final var diagnostics = DiagnosticSink.empty();
final var fileId = new FileId(0);
final PbsAst.File ast = PbsParser.parse(
PbsLexer.lex(source, fileId, diagnostics),
fileId,
diagnostics,
PbsParser.ParseMode.ORDINARY);
assertTrue(diagnostics.isEmpty(), "Parser should accept Doc attributes on struct and service methods");
final var structDecl = assertInstanceOf(PbsAst.StructDecl.class, ast.topDecls().getFirst());
assertEquals("Doc", structDecl.methods().getFirst().attributes().getFirst().name());
final var serviceDecl = assertInstanceOf(PbsAst.ServiceDecl.class, ast.topDecls().get(1));
assertEquals("Doc", serviceDecl.attributes().getFirst().name());
assertEquals("Doc", serviceDecl.methods().getFirst().attributes().getFirst().name());
}
@Test
void shouldRecoverFromMalformedReservedDeclarationsInInterfaceModuleMode() {
final var source = """