Repository navigation
Java Code Indexer v2.0.0
🚀 Java Code Indexer v2.0.0
Java AST-level code indexer with SQLite storage, exposed as an MCP server for AI coding assistants.
📊 开发状态
| 指标 | 状态 |
|---|---|
| 当前版本 | v2.0.0 |
| 开发阶段 | Alpha |
| 稳定性 | 核心功能稳定,API 可能调整 |
| Java 版本要求 | 21+ |
| 最后更新 | ${GITHUB_SHA::8} |
✨ 核心功能
🔍 代码索引
- 符号索引:类、方法、字段的完整定义和位置
- 引用追踪:符号在整个代码库中的使用位置
- 调用图:方法调用关系(调用者/被调用者)
- 增量索引:基于 SHA-1 哈希的智能跳过未变更文件
🛠 MCP 工具
| 工具 | 功能 |
|---|---|
find_symbol |
按名称查找符号,支持通配符 |
find_references |
查找符号的所有引用位置 |
get_call_graph |
方法调用图分析 |
search_code |
搜索符号名和代码内容 |
get_file_info |
文件详情:符号、代码块、调用关系 |
search_config |
搜索配置文件 (YAML/Properties/.env) |
find_dependencies |
搜索项目依赖 (Maven/Gradle) |
📦 分发方式
- Fat JAR:通用 Java 21+ 运行时
- Native Image:GraalVM 原生镜像,启动即时
- Docker:容器化部署,支持多平台
- 多平台支持:Linux (amd64/arm64)、macOS (amd64/arm64)、Windows (amd64)
📝 更新日志
Full Changelog: v1.9.0...v2.0.0
- feat: 添加 Shell 脚本解析器支持
- Revert "feat: 添加 TypeScript 解析器支持"
- test: 简化 McpReferenceStorageTest 避免间歇性失败
- feat: 添加 Python 解析器支持
- feat: 添加 TypeScript 解析器支持
- feat: 为 get_call_graph 添加过滤和限制参数
- fix: 改进引用解析逻辑,确保精确匹配符号
- fix: 改进 get_file_info 返回格式
- fix: 优化 get_call_graph 过滤中间表达式
- fix: 修复注解关联逻辑,支持 find_by_annotation
- fix: 改进引用解析逻辑,支持简单名称查找
- test: 添加 find_references 工具测试
- feat: 改进静态方法和 Record 访问器的类型推断
- feat: 为 get_call_graph 添加 callee 类型推断
- feat: 配置 JavaParser SymbolResolver 解析项目内方法
- fix: 改进 get_call_graph 查询时 callee file 解析
- fix: 集成 JavaParser SymbolResolver 解析调用关系完全限定名
- fix: 改进 JavaParserAdapter 调用关系解析
- fix: 改进 JavaParserAdapter 调用关系解析
- fix: 在索引时填充 callee_file 字段
- fix: 改进 JavaParserAdapter 调用关系解析
- fix: 修复 get_call_graph callees file 查找逻辑
- test: 添加配置热更新和多项目模式测试
- test: 更新测试以匹配新的返回格式
- fix: 统一 search_code 和 search_all_projects 返回格式
- fix: 统一 MCP 工具返回格式,添加缺失的 total 字段
- test: 添加 FileWatcher 数据一致性测试
- test: 添加 MCP 工具返回格式验证测试
- test: 添加 complexity_report 复杂度值验证测试
- fix: get_call_graph callees file 字段显示 unknown 问题
- fix: complexity_report 通过类名查找实际文件路径读取复杂度
- fix: 索引时预计算复杂度存入 code_metrics 表,查询时直接读取
- fix: 简化 complexity_report 避免性能问题,移除文件读取逻辑
- fix(P1-3/P2-2): complexity_report 添加圈复杂度计算
- fix: incrementalReindex 完成后更新 last_indexed_at 时间戳
- fix(P2-3): ProjectContext 持有共享 Indexer 实例,解决 FileWatcher 和 MCP 工具实例不一致问题
- fix(P2-1): index_status last_indexed_at 索引完成时更新时间戳
- fix(P1-2): get_type_hierarchy parents 过滤当前类
- fix(P0+P1): 配置热更新路径修复 + get_call_graph line 字段修复
- fix(P0): search_symbols 通配符支持 - * 转换为 SQL %
- v2.0.0: 生产就绪封板
- v1.9.3: 索引进度通知 + 配置热更新
- v1.9.2: MCP Resources - indexer://stats + indexer://projects
- v1.9.1: CircularDependencyDetector + find_circular_deps MCP 工具
📥 安装说明
Fat JAR
# 1. 索引项目(首次使用)
java -jar java-code-indexer-2.0.0.jar --project-root /path/to/project --index
# 2. 启动 MCP 服务(供 Claude Code / Cursor 等 AI 助手使用)
java -jar java-code-indexer-2.0.0.jar --project-root /path/to/projectNative Image
# Linux/macOS
# 1. 索引项目
./jindexer --project-root /path/to/project --index
# 2. 启动 MCP 服务
./jindexer --project-root /path/to/project
# Windows
# 1. 索引项目
jindexer.exe --project-root /path/to/project --index
# 2. 启动 MCP 服务
jindexer.exe --project-root /path/to/projectDocker
# 1. 索引项目
docker pull sodlinken/jcodeindexer:2.0.0
docker run --rm -v /path/to/project:/project sodlinken/jcodeindexer:2.0.0 --project-root /project --index
# 2. 启动 MCP 服务
docker run --rm -i -v /path/to/project:/project sodlinken/jcodeindexer:2.0.0 --project-root /projectDocker 离线镜像
# 加载离线镜像
docker load < docker-image-2.0.0.tar.gz
# 索引项目
docker run --rm -v /path/to/project:/project sodlinken/jcodeindexer:2.0.0 --project-root /project --index🔧 环境变量
| 变量 | 说明 | 默认值 |
|---|---|---|
INDEXER_THREADS |
索引线程数 | 4 |
INDEXER_LOG_LEVEL |
日志级别 (DEBUG/INFO/WARN/ERROR) | INFO |
⚙️ 配置文件
在项目根目录创建 .jindexer/config.yaml(可选):
# === 项目路径 ===
project_root: /path/to/project
data_dir: .jindexer
# === 索引设置 ===
indexing_threads: 4
max_file_size_kb: 512
extract_javadoc: false
follow_symlinks: false
# === 存储设置 ===
db_name: index.db
# === 日志设置 ===
log_level: INFO
verbose: false
# === 文件监听 ===
watch_enabled: true
watch_interval_seconds: 5
watch_exclude:
- "**/target/**"
- "**/build/**"
- "**/.git/**"
- "**/node_modules/**"