Code Graph RAG Programming Language Support: 14 Languages with Tree-sitter Parser
Code Graph RAG supports 14 programming languages including Python, JavaScript, TypeScript, Java, Go, Rust, C, C++, C#, Dart, Lua, PHP, and Scala (in development), all parsed through Tree-sitter into a unified, language-agnostic knowledge graph.
The code-graph-rag repository (vitali87/code-graph-rag) is a polyglot code analysis engine that ingests source files across multiple languages and constructs a single graph representation for retrieval-augmented generation (RAG) workflows. Unlike language-specific tools, it leverages Tree-sitter—a fast, incremental parser that supplies a uniform abstract syntax tree (AST) for any grammar-equipped language. This design enables cross-language queries without rewriting logic for each target.
How Code Graph RAG Handles Multiple Languages
The engine's language support is built on two architectural principles: grammar reusability and schema uniformity. Tree-sitter provides the parsing foundation, while a language-agnostic graph schema ensures queries work identically regardless of source language.
The Tree-sitter Foundation
Tree-sitter generates deterministic parsers from formal grammars. When codebase_rag.language_spec.LanguageSpec initializes, it discovers available Tree-sitter grammars, registers associated file extensions, and maps AST node types to unified graph entities. This happens in codebase_rag/language_spec.py, which serves as the core configuration layer.
The parser registration logic references codebase_rag/constants/languages.py for the programmatic enumeration of supported languages. This constants file ensures consistency between the parsing engine and documentation.
Supported Programming Languages: Complete Matrix
The authoritative source for language support is docs/architecture/language-support.md. The following matrix reflects the current implementation as of the source analysis:
| Language | Status | Extensions | Core Constructs | Distinctive Features |
|---|---|---|---|---|
| Python | Fully Supported | .py |
Functions, classes, modules | Type inference, decorators, nested functions, package detection |
| JavaScript | Fully Supported | .js, .jsx, .mjs, .cjs |
Functions, classes, modules | ES6 modules, CommonJS, prototype methods, arrow functions |
| TypeScript | Fully Supported | .ts, .mts, .cts |
Functions, classes, modules | Interfaces, type aliases, enums, namespaces |
| TypeScript (TSX) | Fully Supported | .tsx |
Functions, classes, modules | Full TypeScript plus JSX components |
| Java | Fully Supported | .java |
Functions, classes, modules | Generics, annotations, records, sealed classes, concurrency |
| Go | Fully Supported | .go |
Functions, classes (structs), modules | Receiver methods, interfaces, type declarations |
| Rust | Fully Supported | .rs |
Functions, classes (impl blocks), modules | Associated functions, macro_rules! macros, package detection |
| C | Fully Supported | .c |
Functions, classes (structs), modules | Unions, enums, pre-processor includes, package detection |
| C++ | Fully Supported | .cpp, .h, etc. |
Functions, classes, modules | Constructors, destructors, templates, lambdas, C++20 modules, pre-processor macros |
| C# | Fully Supported | .cs |
Functions, classes, modules | Namespaces, records, interfaces, generics, inheritance, using directives |
| Dart | Fully Supported | .dart |
Functions, classes, modules | Mixins, extensions, enhanced enums, Flutter widgets, package/relative imports |
| Lua | Fully Supported | .lua |
Functions, modules | Local/global functions, metatables, closures, coroutines |
| PHP | Fully Supported | .php |
Functions, classes, modules | Interfaces, traits, enums, namespaces, PHP 8 attributes |
| Scala | In Development | .scala, .sc |
Functions, classes, modules | Case classes, objects |
All 13 fully-supported languages plus Scala (in development) feed into the single graph schema. This means a Cypher query targeting Function nodes returns results from Python, Rust, Java, and C++ interchangeably.
Language-Specific Features Deep-Dive
Different languages expose unique constructs that the parser maps to shared graph entities. Here are notable mappings:
- Functions: Captured universally—includes JavaScript arrow functions, Go receiver methods, C++ operator overloads, and Python nested functions
- Classes/Structs: Maps to equivalent constructs—Java classes, Go structs, Rust impl blocks, C structs, Scala case classes
- Modules: File-level and explicit module declarations, with package detection available for Python, Rust, C, C++, and C#
- Advanced constructs: Templates (C++), generics (Java, C#, TypeScript), macros (Rust), decorators (Python), traits (PHP, Rust), mixins (Dart)
Working with Supported Languages: Code Examples
Initialize and Build Graph
from codebase_rag import CodeGraphRAG
# Default configuration enables all supported languages automatically
cgr = CodeGraphRAG(root_path="/path/to/my_repo")
cgr.build_graph() # Parses all files matching supported extensions
This calls the CodeGraphRAG façade defined in codebase_rag/main.py.
Language-Agnostic Query
query = """
MATCH (f:Function {name: "handle_request"})
RETURN f.file_path, f.start_line, f.language
"""
results = cgr.query_cypher(query)
for r in results:
print(f"{r['language']} – {r['file_path']}:{r['start_line']}")
The query returns functions named handle_request from any supported language—Python, Go, JavaScript, etc.—without modification.
CLI Export for Specific Language Project
python -m codebase_rag.cli export-graph \
--root /path/to/python_proj \
--output graph.json
The CLI implementation resides in codebase_rag/cli.py.
Extending Language Support
Adding new languages requires only an existing Tree-sitter grammar. The extension process involves:
- Installing the Tree-sitter grammar package
- Extending
codebase_rag/constants/languages.pywith extensions and metadata - Defining AST node mappings in a new
LanguageSpecconfiguration
No changes to the core graph schema or query engine are necessary.
Summary
- 14 languages are supported: Python, JavaScript, TypeScript, TypeScript (TSX), Java, Go, Rust, C, C++, C#, Dart, Lua, PHP, and Scala (in development)
- Tree-sitter provides the parsing foundation via
codebase_rag/language_spec.py - Unified graph schema enables identical queries across all languages
- Source of truth for language status:
docs/architecture/language-support.md - Entry points:
codebase_rag/main.py(Python API) andcodebase_rag/cli.py(command line)
Frequently Asked Questions
How do I check if a specific programming language version is supported?
The docs/architecture/language-support.md file contains the definitive matrix. For programmatic checks, inspect codebase_rag/constants/languages.py—this module enumerates all registered languages and their associated file extensions. Tree-sitter grammars typically support modern language versions unless explicitly noted.
Can I query across multiple languages in a single graph?
Yes. The unified schema design means MATCH (f:Function) returns functions from Python, Java, Rust, and any other supported language simultaneously. The language property on each node indicates the source language, allowing you to filter or group results as needed.
What happens when I try to parse an unsupported language?
Files with unrecognized extensions are skipped during build_graph(). The parser logs these omissions at the INFO level. To add support, you need a Tree-sitter grammar and a LanguageSpec configuration—no core engine modifications required.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →