rust-call-graph by zhanghandong/rust-skills
npx skills add https://github.com/zhanghandong/rust-skills --skill rust-call-graph使用 LSP 调用层次结构可视化函数调用关系。
/rust-call-graph <函数名> [--depth N] [--direction in|out|both]
选项:
--depth N: 遍历的层级数(默认:3)--direction: in(调用者),out(被调用者),both(双向)示例:
/rust-call-graph process_request - 显示调用者和被调用者/rust-call-graph handle_error --direction in - 仅显示调用者广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
/rust-call-graph main --direction out --depth 5 - 深度被调用者分析获取函数的调用层次结构项。
LSP(
operation: "prepareCallHierarchy",
filePath: "src/handler.rs",
line: 45,
character: 8
)
LSP(
operation: "incomingCalls",
filePath: "src/handler.rs",
line: 45,
character: 8
)
LSP(
operation: "outgoingCalls",
filePath: "src/handler.rs",
line: 45,
character: 8
)
User: "Show call graph for process_request"
│
▼
[1] 查找函数位置
LSP(workspaceSymbol) 或 Grep
│
▼
[2] 准备调用层次结构
LSP(prepareCallHierarchy)
│
▼
[3] 获取传入调用(调用者)
LSP(incomingCalls)
│
▼
[4] 获取传出调用(被调用者)
LSP(outgoingCalls)
│
▼
[5] 递归扩展到深度 N
│
▼
[6] 生成 ASCII 可视化图
## `process_request` 的调用者
main
└── run_server
└── handle_connection
└── process_request ◄── 当前位置
## `process_request` 的被调用者
process_request ◄── 当前位置
├── parse_headers
│ └── validate_header
├── authenticate
│ ├── check_token
│ └── load_user
├── execute_handler
│ └── [dynamic dispatch]
└── send_response
└── serialize_body
## `process_request` 的调用关系图
┌─────────────────┐
│ main │
└────────┬────────┘
│
┌────────▼────────┐
│ run_server │
└────────┬────────┘
│
┌────────▼────────┐
│handle_connection│
└────────┬────────┘
│
┌────────────────────┼────────────────────┐
│ │ │
┌───────▼───────┐ ┌───────▼───────┐ ┌───────▼───────┐
│ parse_headers │ │ authenticate │ │send_response │
└───────────────┘ └───────┬───────┘ └───────────────┘
│
┌───────┴───────┐
│ │
┌──────▼──────┐ ┌──────▼──────┐
│ check_token │ │ load_user │
└─────────────┘ └─────────────┘
生成调用关系图后,提供洞察信息:
## 分析
**入口点:** main, test_process_request
**叶子函数:** validate_header, serialize_body
**热点路径:** main → run_server → handle_connection → process_request
**复杂度:** 12 个函数,3 层深度
**潜在问题:**
- `authenticate` 扇出度高(4 个被调用者)
- `process_request` 被 3 个地方调用(考虑这是否是有意为之)
| 用户表述 | 方向 | 使用场景 |
|---|---|---|
| "谁调用了 X?" | incoming | 影响分析 |
| "X 调用了什么?" | outgoing | 理解实现 |
| "显示调用关系图" | both | 完整视图 |
| "从 main 追踪到 X" | outgoing | 执行路径 |
| 样式 | 最佳适用场景 |
|---|---|
| 树状图(默认) | 简单层次结构 |
| 方框图 | 复杂关系 |
| 扁平列表 | 大量连接 |
| Mermaid | 导出到文档 |
graph TD
main --> run_server
run_server --> handle_connection
handle_connection --> process_request
process_request --> parse_headers
process_request --> authenticate
process_request --> send_response
| 场景 | 查看 |
|---|---|
| 查找定义 | rust-code-navigator |
| 项目结构 | rust-symbol-analyzer |
| Trait 实现 | rust-trait-explorer |
| 安全重构 | rust-refactor-helper |
每周安装量
536
代码仓库
GitHub 星标数
920
首次出现
Jan 22, 2026
安全审计
安装于
opencode490
codex480
gemini-cli471
github-copilot462
amp421
kimi-cli418
Visualize function call relationships using LSP call hierarchy.
/rust-call-graph <function_name> [--depth N] [--direction in|out|both]
Options:
--depth N: How many levels to traverse (default: 3)--direction: in (callers), out (callees), bothExamples:
/rust-call-graph process_request - Show both callers and callees/rust-call-graph handle_error --direction in - Show only callers/rust-call-graph main --direction out --depth 5 - Deep callee analysisGet the call hierarchy item for a function.
LSP(
operation: "prepareCallHierarchy",
filePath: "src/handler.rs",
line: 45,
character: 8
)
LSP(
operation: "incomingCalls",
filePath: "src/handler.rs",
line: 45,
character: 8
)
LSP(
operation: "outgoingCalls",
filePath: "src/handler.rs",
line: 45,
character: 8
)
User: "Show call graph for process_request"
│
▼
[1] Find function location
LSP(workspaceSymbol) or Grep
│
▼
[2] Prepare call hierarchy
LSP(prepareCallHierarchy)
│
▼
[3] Get incoming calls (callers)
LSP(incomingCalls)
│
▼
[4] Get outgoing calls (callees)
LSP(outgoingCalls)
│
▼
[5] Recursively expand to depth N
│
▼
[6] Generate ASCII visualization
## Callers of `process_request`
main
└── run_server
└── handle_connection
└── process_request ◄── YOU ARE HERE
## Callees of `process_request`
process_request ◄── YOU ARE HERE
├── parse_headers
│ └── validate_header
├── authenticate
│ ├── check_token
│ └── load_user
├── execute_handler
│ └── [dynamic dispatch]
└── send_response
└── serialize_body
## Call Graph for `process_request`
┌─────────────────┐
│ main │
└────────┬────────┘
│
┌────────▼────────┐
│ run_server │
└────────┬────────┘
│
┌────────▼────────┐
│handle_connection│
└────────┬────────┘
│
┌────────────────────┼────────────────────┐
│ │ │
┌───────▼───────┐ ┌───────▼───────┐ ┌───────▼───────┐
│ parse_headers │ │ authenticate │ │send_response │
└───────────────┘ └───────┬───────┘ └───────────────┘
│
┌───────┴───────┐
│ │
┌──────▼──────┐ ┌──────▼──────┐
│ check_token │ │ load_user │
└─────────────┘ └─────────────┘
After generating the call graph, provide insights:
## Analysis
**Entry Points:** main, test_process_request
**Leaf Functions:** validate_header, serialize_body
**Hot Path:** main → run_server → handle_connection → process_request
**Complexity:** 12 functions, 3 levels deep
**Potential Issues:**
- `authenticate` has high fan-out (4 callees)
- `process_request` is called from 3 places (consider if this is intentional)
| User Says | Direction | Use Case |
|---|---|---|
| "Who calls X?" | incoming | Impact analysis |
| "What does X call?" | outgoing | Understanding implementation |
| "Show call graph" | both | Full picture |
| "Trace from main to X" | outgoing | Execution path |
| Style | Best For |
|---|---|
| Tree (default) | Simple hierarchies |
| Box diagram | Complex relationships |
| Flat list | Many connections |
| Mermaid | Export to docs |
graph TD
main --> run_server
run_server --> handle_connection
handle_connection --> process_request
process_request --> parse_headers
process_request --> authenticate
process_request --> send_response
| When | See |
|---|---|
| Find definition | rust-code-navigator |
| Project structure | rust-symbol-analyzer |
| Trait implementations | rust-trait-explorer |
| Safe refactoring | rust-refactor-helper |
Weekly Installs
536
Repository
GitHub Stars
920
First Seen
Jan 22, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode490
codex480
gemini-cli471
github-copilot462
amp421
kimi-cli418
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
103,800 周安装
FlowStudio MCP 构建部署 Power Automate 云流指南 | 自动化流程开发
530 周安装
mcp2cli:无需代码,将MCP/OpenAPI/GraphQL实时转换为命令行工具
530 周安装
交互式作品集设计指南:30秒吸引招聘者,提升作品集转化率与个人品牌
530 周安装
每日销售简报AI工具 - 自动生成优先级行动计划,整合日历、CRM和邮件数据
531 周安装
生产排程实战指南:离散制造工厂的有限产能排程、换线优化与瓶颈管理
531 周安装
Angular 21 最佳实践指南:TypeScript、Signals、组件与性能优化
531 周安装