Release 0.4.2: standalone-parser fix (no FQCN, no peglib runtime dep)#30
Conversation
📝 WalkthroughWalkthroughVersion 0.4.2 release adjusts generated parser code to emit a standalone ChangesGenerated Parser RuleId Standalone Refactoring
Allocation-Reduction Generator Design Spike
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
peglib-core/src/test/java/org/pragmatica/peg/action/RuleIdEmissionTest.java (1)
43-45: ⚡ Quick winStrengthen regression assertions for the full standalone contract surface.
These tests currently guard
org.pragmatica.peg.action.RuleIdleakage, but they don’t pin theparseRuleAt(Class<? extends RuleId>, ...)shape or guard other FQCN regressions called out in this release (for examplejava.util.ArrayDeque).Suggested assertion additions
@@ assertThat(source).contains("public sealed interface RuleId {"); assertThat(source).doesNotContain("org.pragmatica.peg.action.RuleId"); + assertThat(source).doesNotContain("java.util.ArrayDeque"); + assertThat(source).contains("Class<? extends RuleId> ruleId"); + assertThat(source).doesNotContain("Class<? extends org.pragmatica.peg.action.RuleId>"); assertThat(source).contains("record Number() implements RuleId"); assertThat(source).contains("record Sum() implements RuleId"); @@ assertThat(source).contains("public sealed interface RuleId {"); assertThat(source).doesNotContain("org.pragmatica.peg.action.RuleId"); + assertThat(source).doesNotContain("java.util.ArrayDeque"); assertThat(source).contains("record Number() implements RuleId"); assertThat(source).contains("record Sum() implements RuleId");Also applies to: 58-60
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@peglib-core/src/test/java/org/pragmatica/peg/action/RuleIdEmissionTest.java` around lines 43 - 45, The test should be extended to assert the full standalone contract surface and prevent FQCN regressions: update RuleIdEmissionTest to additionally assert the presence of the parseRuleAt method signature (e.g., "parseRuleAt(Class<? extends RuleId>") and to assert that no other unexpected fully-qualified class names appear (e.g., doesNotContain("java.util.ArrayDeque"), doesNotContain("org.pragmatica.peg.action.RuleId") remains) so the generated source contains "public sealed interface RuleId {" and "record Number() implements RuleId" while also pinning the parseRuleAt shape and banning prior FQCN leaks.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@peglib-core/src/test/java/org/pragmatica/peg/action/RuleIdEmissionTest.java`:
- Around line 43-45: The test should be extended to assert the full standalone
contract surface and prevent FQCN regressions: update RuleIdEmissionTest to
additionally assert the presence of the parseRuleAt method signature (e.g.,
"parseRuleAt(Class<? extends RuleId>") and to assert that no other unexpected
fully-qualified class names appear (e.g.,
doesNotContain("java.util.ArrayDeque"),
doesNotContain("org.pragmatica.peg.action.RuleId") remains) so the generated
source contains "public sealed interface RuleId {" and "record Number()
implements RuleId" while also pinning the parseRuleAt shape and banning prior
FQCN leaks.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 90cce030-b321-4cf3-956e-d3b6b0efa455
📒 Files selected for processing (11)
CHANGELOG.mdREADME.mddocs/incremental/UNSAFE-GENERATOR-SPIKE.mdpeglib-core/pom.xmlpeglib-core/src/main/java/org/pragmatica/peg/generator/ParserGenerator.javapeglib-core/src/test/java/org/pragmatica/peg/action/RuleIdEmissionTest.javapeglib-formatter/pom.xmlpeglib-incremental/pom.xmlpeglib-maven-plugin/pom.xmlpeglib-playground/pom.xmlpom.xml
Single-fix maintenance release.
Fixed
org.pragmatica.peg.action.RuleId,java.util.ArrayDeque, etc.). The standalone-parser contract documented onParserGeneratoris now enforced end-to-end.[0.4.2]entry for full details.Why this is needed
Downstream projects without peglib on their compile classpath could not build the emitted source, despite the generator's documented contract that generated parsers depend only on
pragmatica-lite:core. The emittedRuleIdinterface declaredextends org.pragmatica.peg.action.RuleIdand the emittedparseRuleAtsignature used the FQCN — both vestigial since the generatedwithActionAPI uses string-based dispatch.Test plan
RuleIdEmissionTestupdated to assert standalone shape + absence oforg.pragmatica.peg.action.RuleIdin emitted sourcemvn verifyBUILD SUCCESSSummary by CodeRabbit
Bug Fixes
RuleIdinterface, improving portability. Existing generated parsers must be regenerated to apply this fix.Documentation