Repository navigation
fix: parse records inside Java annotation interfaces - #35
Merged
Merged
Conversation
Retain record members within annotation bodies and preserve sibling and following declarations, including generic records and compact constructors. Co-authored-by: WillBooster (Codex CLI) <agent@willbooster.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
@interface Config { record Value(int number) {} }produces an error. In the complete fixture, recovery moves later records outside the annotation interface and loses the following class. The fixture compiles cleanly with JDK 27. JLS 27 §9.6.1 permits class declarations in annotation interface bodies, including records.This addresses
grammar-orchard/tree-sitter-java-orchard#15/ commit33cd02c3.Requirements
Customer Summary
Records inside annotation interfaces retain their normal declaration structure and fields, including generic records and annotated compact constructors. Other members and the following class stay in their correct scopes.
Technical Summary
Add
record_declarationto the annotation body member choices. The only schema change allows this existing named node as a child ofannotation_type_body; every other schema entry and field stays unchanged.The corpus asserts three nested records, generic parameters and implemented interfaces, an annotated compact constructor, sibling class/interface/enum/annotation declarations, and a following class that refers to the nested records.
Testing
bun run verifypasses with zero code-gauge findings; 67 focused tests across 11 files pass.cargo test --lockedpasses the native load test and executable documentation.record_declarationchild ofannotation_type_body. Twenty-nine unchanged full trees/query controls, all 240 whitespace-sensitive trees, and six further CST/query controls match published 8.0.0 exactly.Notes
The first Test workflow attempt failed during the Chromium download with a CDN certificate hostname mismatch; retrying the failed job passed on the unchanged commit.
Generated C is retained exactly as emitted by the runtime 9 CLI, including trailing whitespace; the authored-file whitespace check passes.