Skip to content

fix: parse records inside Java annotation interfaces - #35

Merged
exKAZUu merged 1 commit into
mainfrom
fix/annotation-record-members
Oct 21, 2026
Merged

exKAZUu merged 1 commit into
mainfrom
fix/annotation-record-members

Conversation

@exKAZUu

@exKAZUu exKAZUu commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

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 / commit 33cd02c3.

Requirements

  • required: Improve our forked grammar repositories, excluding CSS and Markdown, as much as possible, ignoring backward compatibility.
  • required: Review existing fork issues and major upstream issues, PRs, and recent commits; prevent duplicate PRs and open a dedicated PR from the latest main for each item that warrants resolution.
  • required: Run review-booster and complete-pr concurrently, then release to publish the changes.
  • required: Parse Java record declarations inside annotation interfaces, retaining their enclosing body, record fields, sibling members, and following declarations.
  • required: Preserve ordinary annotations, other record and declaration syntax, shipped queries, source ranges and consistent incremental editing.
  • chosen: Add the existing record_declaration rule to annotation_type_body rather than introducing a new record node or changing existing record fields, because Java permits this class declaration form and callers already consume the same record structure elsewhere.

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_declaration to the annotation body member choices. The only schema change allows this existing named node as a child of annotation_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

  • Checksummed official JDK 27.0.1.0.2 compiles the full fixture with empty diagnostics. Actual public Java 8.0.0 rejects it and loses declaration scopes.
  • Canonical generation passes all 160 native and Wasm corpus cases without warnings. All 160 pass 100 incremental-fuzz iterations with 10 edits and seed 1.
  • bun run verify passes with zero code-gauge findings; 67 focused tests across 11 files pass.
  • cargo test --locked passes the native load test and executable documentation.
  • Wasm API checks assert all three records within the annotation body, sibling/following class names, compact constructor and shipped query captures; six rename/comment/annotation edit-undo states match fresh full metadata, fields, anonymous tokens and query captures.
  • The schema differs from published 8.0.0 only by allowing a record_declaration child of annotation_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.
  • Full cross-platform, browser, Worker, example, and robustness checks run in PR CI.

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.

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>
@exKAZUu exKAZUu self-assigned this Oct 21, 2026
@exKAZUu
exKAZUu merged commit 3ee816d into main Oct 21, 2026
12 of 13 checks passed
@exKAZUu
exKAZUu deleted the fix/annotation-record-members branch October 21, 2026 23:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant