rust-symbol-analyzer

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Rust 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:
  • /rust-symbol-analyzer
    - Analyze entire project
  • /rust-symbol-analyzer src/lib.rs
    - Analyze single file
  • /rust-symbol-analyzer --type trait
    - List all traits in project
/rust-symbol-analyzer [file.rs] [--type struct|trait|fn|mod]
示例:
  • /rust-symbol-analyzer
    - 分析整个项目
  • /rust-symbol-analyzer src/lib.rs
    - 分析单个文件
  • /rust-symbol-analyzer --type trait
    - 列出项目中的所有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

项目概览

undefined
undefined

Project 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
undefined

By Symbol Type

按符号类型分类

undefined
undefined

Symbols by Type

按符号类型分类

Structs (12)

结构体 (12个)

NameLocationFieldsDerives
Configsrc/config.rs:105Debug, Clone
Usersrc/models/user.rs:84Debug, Serialize
Ordersrc/models/order.rs:156Debug, Serialize
...
名称位置字段派生特性
Configsrc/config.rs:105Debug, Clone
Usersrc/models/user.rs:84Debug, Serialize
Ordersrc/models/order.rs:156Debug, Serialize
...

Traits (4)

Trait (4个)

NameLocationMethodsImplementors
Handlersrc/handlers/mod.rs:53AuthHandler, ApiHandler
Repositorysrc/db/mod.rs:125UserRepo, OrderRepo
...
名称位置方法实现者
Handlersrc/handlers/mod.rs:53AuthHandler, ApiHandler
Repositorysrc/db/mod.rs:125UserRepo, OrderRepo
...

Functions (25)

函数 (25个)

NameLocationVisibilityAsync
mainsrc/main.rs:10pubyes
parse_configsrc/config.rs:45pubno
...
名称位置可见性是否异步
mainsrc/main.rs:10pub
parse_configsrc/config.rs:45pub
...

Enums (6)

枚举 (6个)

NameLocationVariants
Errorsrc/error.rs:58
Statussrc/models/order.rs:54
...
undefined
名称位置变体
Errorsrc/error.rs:58
Statussrc/models/order.rs:54
...
undefined

Single File Analysis

单个文件分析

undefined
undefined

src/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
undefined
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
undefined

Analysis Features

分析特性

Complexity Metrics

复杂度指标

undefined
undefined

Complexity Analysis

复杂度分析

FileStructsFunctionsLinesComplexity
src/handlers/auth.rs28150Medium
src/models/user.rs312200High
src/config.rs1350Low
Hotspots: Files with high complexity that may need refactoring
  • src/handlers/api.rs (15 functions, 300 lines)
undefined
文件结构体数量函数数量行数复杂度
src/handlers/auth.rs28150中等
src/models/user.rs312200
src/config.rs1350
热点文件: 复杂度高可能需要重构的文件
  • src/handlers/api.rs (15个函数,300行)
undefined

Dependency Analysis

依赖分析

undefined
undefined

Internal 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/
undefined
auth.rs ├── 导入自: config.rs, models/user.rs, db/mod.rs └── 被导入至: main.rs, handlers/mod.rs
user.rs ├── 导入自: (无 - 叶子模块) └── 被导入至: auth.rs, api.rs, tests/
undefined

Symbol Types

符号类型

TypeIconLSP Kind
Module📦Module
Struct🏗️Struct
Enum🔢Enum
Trait📜Interface
FunctionFunction
Method🔧Method
Constant🔒Constant
Field📎Field
类型图标LSP 类型
模块📦Module
结构体🏗️Struct
枚举🔢Enum
Trait📜Interface
函数Function
方法🔧Method
常量🔒Constant
字段📎Field

Common Queries

常见查询

User SaysAnalysis
"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

相关工具

WhenSee
Navigate to symbolrust-code-navigator
Call relationshipsrust-call-graph
Trait implementationsrust-trait-explorer
Safe refactoringrust-refactor-helper
场景查看
跳转到符号rust-code-navigator
调用关系rust-call-graph
Trait实现rust-trait-explorer
安全重构rust-refactor-helper