tree-sitter-java

A fast, incremental Java grammar for the tree-sitter parsing library

Library
Cargo
v0.23.5
274 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
55 /100 Fair
Development Activity 44
Maintenance 20
Community 76
Maturity 60
Momentum 20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
71 /100 Good
Architecture 76
Code Quality 73
Innovation 70
Learning Curve 65

tree-sitter-java is the official Java language grammar for tree-sitter, the incremental parsing library used by editors and developer tools to build concrete syntax trees. It defines Java’s syntax (classes, interfaces, generics, annotations, records) in a declarative grammar that compiles to a generated C parser plus bindings for Rust, Node.js, Python, Go, and Swift.

Editors, linters, and static-analysis tools consume this grammar to parse Java source incrementally and error-tolerantly, enabling syntax highlighting, code folding, and structural navigation without a full javac front-end.

What You Get

  • A complete, actively maintained Java grammar covering modern syntax including records, sealed classes, and annotations
  • A generated, dependency-free C parser (parser.c) compiled from the grammar for use in any host language
  • Official bindings for Rust, Go, Node.js, Python, and Swift for embedding the grammar directly in tooling
  • Highlight and tag queries (queries/highlights.scm, queries/tags.scm) mapping syntax nodes to editor categories
  • A corpus of test fixtures (test/corpus, test/highlight) validating grammar correctness against real Java code

Common Use Cases

  • Editor syntax highlighting - power tree-sitter-based highlighting for Java files in editors like Neovim, Helix, and Zed
  • Code navigation tooling - build ‘jump to definition’ and structural outlines by querying the parsed Java syntax tree
  • Static analysis and linters - traverse the concrete syntax tree to implement custom Java lint rules without invoking javac
  • Language server implementations - use the grammar as the incremental parsing layer underneath a Java LSP server

Under The Hood

Architecture - The grammar is authored in grammar.js as a JavaScript DSL describing Java’s syntax rules (declarations, statements, expressions, generics, annotations). The tree-sitter CLI compiles this into a generated, table-driven src/parser.c, with src/node-types.json describing the resulting AST node schema.

Tech Stack - The grammar source is JavaScript, but the shipped artifact is generated C code with zero runtime dependencies beyond tree-sitter-language; the repo ships first-class bindings for Rust (Cargo.toml), Go (go.mod), Node.js (package.json, binding.gyp), Python (pyproject.toml, setup.py), and Swift (Package.swift).

Code Quality - Correctness is validated through test/corpus (parse-tree fixtures) and a separate test/highlight suite exercising the highlight queries; CI runs across the various language bindings before each Cargo/npm/PyPI release, keeping the grammar current as Java language features evolve.

API Design - Consumers interact through a minimal surface: a single exported language constant handed to the generic tree-sitter runtime API, so there’s effectively no Java-specific API to learn beyond tree-sitter’s own parser/query interface, keeping integration overhead low.

Used by 6 apps in this directory

Rust
52%
Apache 2.0

cocoindex

AI Development · Data Engineering

11,607

An incremental data indexing engine that keeps AI agent context perpetually fresh by reprocessing only what changed.

View details
87
Repo Health
85
Technical
65
Dependency
Built with
Rust 52%
Python 48%
Updated 4 days ago
C
83%
MIT

codegraph

AI Code Assistants · Developer Tools

72,201

A pre-indexed code knowledge graph that cuts AI tool calls by 58% and token costs by 16% — auto-syncing, 100% local, works with Claude Code, Cursor, Codex, and more.

View details
84
Repo Health
85
Technical
70
Dependency
Built with
C 83%
TypeScript 14%
Updated 5 days ago
Python
100%
MIT

Graphify

AI Agents

121,917

A YC-backed, open-source knowledge graph skill for AI coding assistants — type /graphify and it maps your entire project (code, docs, PDFs, images, videos) into a queryable graph instead of grepping through files.

View details
83
Repo Health
73
Technical
72
Dependency
Built with
Python 100%
Updated 5 days ago
Python
75%
AGPL 3.0

OpenViking

AI Development · AI Memory · Databases

38,819

An open-source context database that gives AI agents a unified filesystem for memory, resources, and skills with hierarchical tiered retrieval.

View details
85
Repo Health
75
Technical
64
Dependency
Built with
Python 75%
Rust 12%
Updated 4 days ago
Rust
93%
Other

Tabby

AI Code Assistants

33,892

Self-hosted AI coding assistant — run GitHub Copilot-grade code completion on your own hardware with no cloud dependency.

View details
58
Repo Health
78
Technical
61
Dependency
Built with
Rust 93%
Updated 3 months ago
Rust
90%
MIT

Zeron

AI Code Assistants · Developer Tools

2,254

A native, Rust-built control plane that runs and steers Claude Code, Codex, Cursor, Devin, and other coding agents from any device, locally by default with optional CRDT-synced multi-device control.

View details
78
Repo Health
82
Technical
78
Dependency
Built with
Rust 90%
Updated 4 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers