Skip to content

docs: add Java query examples - #41

Merged
exKAZUu merged 2 commits into
mainfrom
docs/java-query-examples
Oct 22, 2026
Merged

exKAZUu merged 2 commits into
mainfrom
docs/java-query-examples

Conversation

@exKAZUu

@exKAZUu exKAZUu commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

Why

The README shows a modifier query but does not explain how to run queries or find common declarations and annotations. This addresses the usage gap described in tree-sitter/tree-sitter-java#228 with examples for this fork's grammar.

Requirements

  • required: Improve the forked grammar repositories, excluding CSS and Markdown, ignoring backward compatibility; review fork issues and major upstream issues, PRs and recent commits, and resolve eligible items.
  • required: Prevent duplicate PRs, and create a dedicated PR from the latest main for each identified issue or upstream item that warrants resolution.
  • required: Complete PRs left unattended for at least four hours, then run review-agent, complete-pr and release in that order.
  • required: Provide examples for querying annotations, classes, methods and other declarations, with enough explanation to distinguish grammar fields from capture labels.
  • chosen: Keep this change to README usage examples, using the current public node types and runtime API; verify the copyable queries through the actual parser rather than adding tests of external facts.
  • chosen: Cover five declaration kinds and simple or qualified annotations, and retain the existing structural public-static modifier query because it avoids matching annotation text.
  • chosen: Use a docs-only Conventional Commit and the existing release workflow without changing release rules. This documentation change does not independently request a package version; the workflow can complete any pending release from main.

Customer Summary

The README explains capture labels and fields, shows the JavaScript query API, and supplies queries for classes, interfaces, enums, records, annotation interfaces, methods, annotations and name filters.

Technical Summary

The Node.js example keeps the loaded language available for querying. A Queries subsection links the syntax reference and contains copyable examples; the existing modifier example remains. Rust usage has its own subsection after the query examples. The branch includes the latest main and its runtime 10 compatibility changes.

Testing

  • Executed all five README Scheme blocks against the regenerated grammar with runtime 10.0.2: five declaration kinds, both methods, marker and qualified argument annotations, the class-name predicate, and the public static method were captured.
  • Executed the JavaScript query example; it prints class.name Main.
  • bun run build-wasm and bun run verify passed; code-gauge reported no violations.
  • All checks on the pushed head passed, including Rust, the full test workflow, platform tests and fuzzing. Read-only review found no actionable defects.

Notes

The documentation commit alone creates no new package version under the existing release rules. npm README contents update when the release workflow publishes a package.

exKAZUu and others added 2 commits October 22, 2026 10:41
@exKAZUu exKAZUu self-assigned this Oct 22, 2026
@exKAZUu
exKAZUu merged commit c732432 into main Oct 22, 2026
10 checks passed
@exKAZUu
exKAZUu deleted the docs/java-query-examples branch October 22, 2026 09:57
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