A multi-language code graph parsing service built with Tree-sitter. It constructs searchable code graphs for symbol definition lookup, reference tracking, and call graph analysis.
- Multi-language Support: Currently supports Java and Go, extensible to more languages
- Symbol Definition Lookup: Quickly locate where functions, classes, and methods are defined
- Reference Tracking: Find all usages of a symbol across the codebase
- Call Graph Analysis: Analyze function call relationships (callers/callees)
- Project-level Parsing: Parse entire projects and build cross-file code graphs
- Incremental Updates: Support for incremental parsing on code changes (WIP)
# Clone the repository
git clone https://github.com/yourname/codegraph.git
cd codegraph
# Build
cargo build --release
# Install to system path
cp target/release/codegraph /usr/local/bin/# Parse current directory
codegraph parse --path . --name myproject
# Parse a specific directory
codegraph parse --path /path/to/project --name myproject
# Parse only specific languages
codegraph parse --path . --name myproject --languages java,go# Find symbol definition
codegraph query definition --symbol "UserService"
# Find all references to a symbol
codegraph query references --symbol "getUserById" --limit 50
# Search symbols by name pattern
codegraph query symbols --query "User" --symbol-type class --limit 20
# Get call graph
codegraph query callgraph --symbol "handleRequest" --depth 2 --direction both# List all parsed projects
codegraph projects
# Query a specific project
codegraph query --project myproject symbols --query "Service"Parse a project and build the code graph.
codegraph parse [OPTIONS]
Options:
-p, --path <PATH> Project root path
-n, --name <NAME> Project name (defaults to directory name)
-l, --languages <LANGS> Languages to parse (comma-separated, e.g., java,go)
-d, --database <FILE> Database file path [default: codegraph.db]Query the code graph.
Find where a symbol is defined.
codegraph query definition --symbol <NAME>Find all references to a symbol.
codegraph query references --symbol <NAME> [--limit <N>]Search for symbols by name pattern.
codegraph query symbols --query <PATTERN> [--symbol-type <TYPE>] [--limit <N>]
Symbol types: class, interface, struct, method, function, field, variableGet the call graph for a symbol.
codegraph query callgraph --symbol <NAME> [--depth <N>] [--direction <DIR>]
Directions: callers, callees, bothList all parsed projects.
codegraph projects [--database <FILE>]List supported languages.
codegraph languagesCreate a config.toml file (optional):
[server]
host = "127.0.0.1"
port = 8080
cors_enabled = true
cors_origins = ["*"]
[database]
path = "codegraph.db"
pool_size = 4
[logging]
level = "info" # trace, debug, info, warn, error
format = "pretty" # pretty, json, compactAll query results are returned in JSON format:
{
"found": true,
"definition": {
"file": "/path/to/UserService.java",
"line": 15,
"column": 1,
"node_type": "class",
"name": "UserService",
"qualified_name": "com.example.UserService"
}
}- Language: Rust
- Syntax Parsing: tree-sitter
- Storage: SQLite (rusqlite)
- CLI: clap
- Serialization: serde, serde_json, toml
codegraph/
βββ src/
β βββ main.rs # CLI entry point
β βββ core/ # Core engine
β β βββ config.rs # Configuration
β β βββ parser.rs # Code parser
β β βββ query.rs # Query executor
β β βββ ...
β βββ storage/ # Storage layer
β β βββ sqlite.rs # SQLite implementation
β β βββ models.rs # Data models
β βββ languages/ # Language support
β β βββ java/ # Java support
β β βββ go/ # Go support
β βββ server/ # HTTP server (optional)
βββ config.example.toml # Example configuration
βββ Cargo.toml
# Run tests
cargo test
# Development build
cargo build
# Verbose logging
codegraph --verbose parse --path .MIT