Skip to content

feat!: expose Java declaration modifiers as named nodes - #24

Merged
exKAZUu merged 3 commits into
mainfrom
feat/structural-modifiers
Oct 20, 2026
Merged

exKAZUu merged 3 commits into
mainfrom
feat/structural-modifiers

Conversation

@exKAZUu

@exKAZUu exKAZUu commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

Why

Named declaration modifier nodes let structural tools represent visibility and modifier changes independently of annotations. tree-sitter/tree-sitter-java#204 and tree-sitter/tree-sitter-java#211 request this structural access; Mergiraf's current Java language configuration uses separate visibility and modifier nodes to merge modifier edits and distinguish them from annotations.

Requirements

  • required: Improve our forked tree-sitter repository and all forked grammar repositories as much as possible, ignoring backward compatibility.
  • required: Review existing issues and major upstream issues, PRs, and recent commits; check existing PRs before opening a dedicated PR from the latest main for each eligible item.
  • required: Run review-booster and complete-pr concurrently, then release and publish the changes.
  • required: Make method visibility accessible independently of annotations, as requested in tree-sitter/tree-sitter-java#204.
  • required: Preserve valid Java parsing, incremental editing, and the shipped highlight and tag queries.
  • chosen: Represent access keywords as visibility and other declaration modifier keywords as modifier, matching the useful grouping in the upstream proposal and structural merge tooling without introducing a node type for each keyword.
  • chosen: Retain anonymous keyword children and distinct annotation nodes so existing keyword captures and annotation queries keep their meaning.
  • chosen: Keep this PR limited to structural declaration modifiers and build on the released runtime 7.0.5 from main, because ABI migration is already provided by PR feat!: migrate Java grammar to runtime ABI 6 #23.

Customer Summary

Declaration modifiers now expose named visibility and modifier children for structural tools and queries. Queries can select public static methods independently of annotations, including after incremental edits. Keyword tokens remain available for highlighting.

Technical Summary

Add the two grammar rules under modifiers, regenerate the parser and node metadata, and update corpus expectations for the additional nodes. The README includes a query example. The new public Wasm API regression selects an annotated public static method, changes its visibility incrementally, and checks that the query result changes while both methods remain intact. Annotation text deliberately contains access keywords to verify structural selection.

Mergiraf's concrete consumer configuration is in its current Java language definition, which groups visibility/modifier children separately from annotations and gives them independent signatures.

Testing

  • bun run build-wasm: canonical generation and Wasm compilation passed from all 151 corpus inputs.
  • bun run verify: passed with no code-gauge violations.
  • Selected native/Wasm corpus, query, syntax, recovery performance, and 1,000-iteration incremental fuzz checks passed: 68 tests across 11 files, including runtime version alignment after integration with the released ABI 6 runtime.
  • cargo test --locked: native binding and executable documentation passed.
  • Loaded the built Wasm through the Web runtime and compiled both shipped queries; class/method tags and public/private keyword highlights remained correct.
  • PR CI passed on the reviewed commit, including cross-platform and robustness checks.
  • Review-booster completed on the unchanged commit with no findings from three successful reviewers. Two provider routes were unavailable; full review coverage is unverified.

Notes

The AST change adds named children beneath modifiers. Consumers that assume its only named children are annotations must account for the additional nodes. The parser is regenerated with runtime 7.0.5 after integrating the released main branch. The Rust usage example selects major version 5 for the breaking AST release.

exKAZUu and others added 3 commits October 21, 2026 01:44
Represent declaration access keywords as visibility nodes and other
modifier keywords as modifier nodes, preserving their keyword tokens
and annotation children for queries and structural tooling.

Co-authored-by: WillBooster (Codex CLI) <Codex CLI@willbooster.com>
Regenerate the structural modifier parser with the runtime released in
Java grammar 4.0.0 and validate its queries and incremental edits.

Co-authored-by: WillBooster (Codex CLI) <Codex CLI@willbooster.com>
Co-authored-by: WillBooster (Codex CLI) <Codex CLI@willbooster.com>
@exKAZUu exKAZUu self-assigned this Oct 20, 2026
@exKAZUu
exKAZUu merged commit cdfc38f into main Oct 20, 2026
10 checks passed
@exKAZUu
exKAZUu deleted the feat/structural-modifiers branch October 20, 2026 17:25
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