rust-symbol-analyzer
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseRust Symbol Analyzer
Rust 符号分析器
Analyze project structure by examining symbols across your Rust codebase.
通过检查Rust代码库中的符号来分析项目结构。
Usage
使用方法
/rust-symbol-analyzer [file.rs] [--type struct|trait|fn|mod]Examples:
- - Analyze entire project
/rust-symbol-analyzer - - Analyze single file
/rust-symbol-analyzer src/lib.rs - - List all traits in project
/rust-symbol-analyzer --type trait
/rust-symbol-analyzer [file.rs] [--type struct|trait|fn|mod]示例:
- - 分析整个项目
/rust-symbol-analyzer - - 分析单个文件
/rust-symbol-analyzer src/lib.rs - - 列出项目中的所有trait
/rust-symbol-analyzer --type trait
LSP Operations
LSP 操作
1. Document Symbols (Single File)
1. 文档符号(单个文件)
Get all symbols in a file with their hierarchy.
LSP(
operation: "documentSymbol",
filePath: "src/lib.rs",
line: 1,
character: 1
)Returns: Nested structure of modules, structs, functions, etc.
获取文件中所有符号及其层级结构。
LSP(
operation: "documentSymbol",
filePath: "src/lib.rs",
line: 1,
character: 1
)返回结果: 模块、结构体、函数等的嵌套结构。
2. Workspace Symbols (Entire Project)
2. 工作区符号(整个项目)
Search for symbols across the workspace.
LSP(
operation: "workspaceSymbol",
filePath: "src/lib.rs",
line: 1,
character: 1
)Note: Query is implicit in the operation context.
在整个工作区中搜索符号。
LSP(
operation: "workspaceSymbol",
filePath: "src/lib.rs",
line: 1,
character: 1
)注意: 查询操作隐含在上下文当中。
Workflow
工作流程
User: "What's the structure of this project?"
│
▼
[1] Find all Rust files
Glob("**/*.rs")
│
▼
[2] Get symbols from each key file
LSP(documentSymbol) for lib.rs, main.rs
│
▼
[3] Categorize by type
│
▼
[4] Generate structure visualization用户: "这个项目的结构是什么样的?"
│
▼
[1] 查找所有Rust文件
Glob("**/*.rs")
│
▼
[2] 从关键文件中获取符号
对lib.rs、main.rs执行LSP(documentSymbol)
│
▼
[3] 按类型分类
│
▼
[4] 生成结构可视化结果Output Format
输出格式
Project Overview
项目概览
undefinedundefinedProject Structure: my-project
项目结构: my-project
Modules
模块
├── src/
│ ├── lib.rs (root)
│ ├── config/
│ │ ├── mod.rs
│ │ └── parser.rs
│ ├── handlers/
│ │ ├── mod.rs
│ │ ├── auth.rs
│ │ └── api.rs
│ └── models/
│ ├── mod.rs
│ ├── user.rs
│ └── order.rs
└── tests/
└── integration.rs
undefined├── src/
│ ├── lib.rs (根模块)
│ ├── config/
│ │ ├── mod.rs
│ │ └── parser.rs
│ ├── handlers/
│ │ ├── mod.rs
│ │ ├── auth.rs
│ │ └── api.rs
│ └── models/
│ ├── mod.rs
│ ├── user.rs
│ └── order.rs
└── tests/
└── integration.rs
undefinedBy Symbol Type
按符号类型分类
undefinedundefinedSymbols by Type
按符号类型分类
Structs (12)
结构体 (12个)
| Name | Location | Fields | Derives |
|---|---|---|---|
| Config | src/config.rs:10 | 5 | Debug, Clone |
| User | src/models/user.rs:8 | 4 | Debug, Serialize |
| Order | src/models/order.rs:15 | 6 | Debug, Serialize |
| ... |
| 名称 | 位置 | 字段 | 派生特性 |
|---|---|---|---|
| Config | src/config.rs:10 | 5 | Debug, Clone |
| User | src/models/user.rs:8 | 4 | Debug, Serialize |
| Order | src/models/order.rs:15 | 6 | Debug, Serialize |
| ... |
Traits (4)
Trait (4个)
| Name | Location | Methods | Implementors |
|---|---|---|---|
| Handler | src/handlers/mod.rs:5 | 3 | AuthHandler, ApiHandler |
| Repository | src/db/mod.rs:12 | 5 | UserRepo, OrderRepo |
| ... |
| 名称 | 位置 | 方法 | 实现者 |
|---|---|---|---|
| Handler | src/handlers/mod.rs:5 | 3 | AuthHandler, ApiHandler |
| Repository | src/db/mod.rs:12 | 5 | UserRepo, OrderRepo |
| ... |
Functions (25)
函数 (25个)
| Name | Location | Visibility | Async |
|---|---|---|---|
| main | src/main.rs:10 | pub | yes |
| parse_config | src/config.rs:45 | pub | no |
| ... |
| 名称 | 位置 | 可见性 | 是否异步 |
|---|---|---|---|
| main | src/main.rs:10 | pub | 是 |
| parse_config | src/config.rs:45 | pub | 否 |
| ... |
Enums (6)
枚举 (6个)
| Name | Location | Variants |
|---|---|---|
| Error | src/error.rs:5 | 8 |
| Status | src/models/order.rs:5 | 4 |
| ... |
undefined| 名称 | 位置 | 变体 |
|---|---|---|
| Error | src/error.rs:5 | 8 |
| Status | src/models/order.rs:5 | 4 |
| ... |
undefinedSingle File Analysis
单个文件分析
undefinedundefinedsrc/handlers/auth.rs
src/handlers/auth.rs
Symbols Hierarchy
符号层级结构
mod auth
├── struct AuthHandler
│ ├── field: config: Config
│ ├── field: db: Pool
│ └── impl AuthHandler
│ ├── fn new(config, db) -> Self
│ ├── fn authenticate(&self, token) -> Result<User>
│ └── fn refresh_token(&self, user) -> Result<Token>
├── struct Token
│ ├── field: value: String
│ └── field: expires: DateTime
├── enum AuthError
│ ├── InvalidToken
│ ├── Expired
│ └── Unauthorized
└── impl Handler for AuthHandler
├── fn handle(&self, req) -> Response
└── fn name(&self) -> &str
undefinedmod auth
├── struct AuthHandler
│ ├── field: config: Config
│ ├── field: db: Pool
│ └── impl AuthHandler
│ ├── fn new(config, db) -> Self
│ ├── fn authenticate(&self, token) -> Result<User>
│ └── fn refresh_token(&self, user) -> Result<Token>
├── struct Token
│ ├── field: value: String
│ └── field: expires: DateTime
├── enum AuthError
│ ├── InvalidToken
│ ├── Expired
│ └── Unauthorized
└── impl Handler for AuthHandler
├── fn handle(&self, req) -> Response
└── fn name(&self) -> &str
undefinedAnalysis Features
分析特性
Complexity Metrics
复杂度指标
undefinedundefinedComplexity Analysis
复杂度分析
| File | Structs | Functions | Lines | Complexity |
|---|---|---|---|---|
| src/handlers/auth.rs | 2 | 8 | 150 | Medium |
| src/models/user.rs | 3 | 12 | 200 | High |
| src/config.rs | 1 | 3 | 50 | Low |
Hotspots: Files with high complexity that may need refactoring
- src/handlers/api.rs (15 functions, 300 lines)
undefined| 文件 | 结构体数量 | 函数数量 | 行数 | 复杂度 |
|---|---|---|---|---|
| src/handlers/auth.rs | 2 | 8 | 150 | 中等 |
| src/models/user.rs | 3 | 12 | 200 | 高 |
| src/config.rs | 1 | 3 | 50 | 低 |
热点文件: 复杂度高可能需要重构的文件
- src/handlers/api.rs (15个函数,300行)
undefinedDependency Analysis
依赖分析
undefinedundefinedInternal Dependencies
内部依赖关系
auth.rs
├── imports from: config.rs, models/user.rs, db/mod.rs
└── imported by: main.rs, handlers/mod.rs
user.rs
├── imports from: (none - leaf module)
└── imported by: auth.rs, api.rs, tests/
undefinedauth.rs
├── 导入自: config.rs, models/user.rs, db/mod.rs
└── 被导入至: main.rs, handlers/mod.rs
user.rs
├── 导入自: (无 - 叶子模块)
└── 被导入至: auth.rs, api.rs, tests/
undefinedSymbol Types
符号类型
| Type | Icon | LSP Kind |
|---|---|---|
| Module | 📦 | Module |
| Struct | 🏗️ | Struct |
| Enum | 🔢 | Enum |
| Trait | 📜 | Interface |
| Function | ⚡ | Function |
| Method | 🔧 | Method |
| Constant | 🔒 | Constant |
| Field | 📎 | Field |
| 类型 | 图标 | LSP 类型 |
|---|---|---|
| 模块 | 📦 | Module |
| 结构体 | 🏗️ | Struct |
| 枚举 | 🔢 | Enum |
| Trait | 📜 | Interface |
| 函数 | ⚡ | Function |
| 方法 | 🔧 | Method |
| 常量 | 🔒 | Constant |
| 字段 | 📎 | Field |
Common Queries
常见查询
| User Says | Analysis |
|---|---|
| "What structs are in this project?" | workspaceSymbol + filter |
| "Show me src/lib.rs structure" | documentSymbol |
| "Find all async functions" | workspaceSymbol + async filter |
| "List public API" | documentSymbol + pub filter |
| 用户提问 | 分析操作 |
|---|---|
| "这个项目里有哪些结构体?" | workspaceSymbol + 过滤 |
| "展示src/lib.rs的结构" | documentSymbol |
| "查找所有异步函数" | workspaceSymbol + 异步过滤 |
| "列出公开API" | documentSymbol + pub过滤 |
Related Skills
相关工具
| When | See |
|---|---|
| Navigate to symbol | rust-code-navigator |
| Call relationships | rust-call-graph |
| Trait implementations | rust-trait-explorer |
| Safe refactoring | rust-refactor-helper |
| 场景 | 查看 |
|---|---|
| 跳转到符号 | rust-code-navigator |
| 调用关系 | rust-call-graph |
| Trait实现 | rust-trait-explorer |
| 安全重构 | rust-refactor-helper |