|
|
在最近几个版本,Claude Code 带来了 LSP 支持,
和别的 CodeAgent 一样,CC 目前仅适配 stdio 方式交互的 lsp Server (利用子进程 spawn 出 server)
接着通过经典的 vscode-jsonrpc 握手,
对下列 feat 提供支持
Specification (https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#capabilities) 能力
Specification (https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#workspace_workspaceFolders) workspaceFolders 和 rootUri
有意思的是这里做了一层 Map (废话,Hover 这种 feat 是给人用的,CodeAgent 想去读文档肯定不需要模拟鼠标覆盖)
把 Agent 的 operation, filePath, line, character
映射到 LSP 请求(具体的来说,实现了 definition references hover implementation documentSymbol symbol prepareCallHierarchy)
同时,在 CC 每次 FileWrite 或 FileEdit 后,触发 LSP Server 缓存刷新
其实在 2.0.71 就有 LSP 的一些基本工具,.76 更新了 call hierarchy ,方便查看调用层级 |
|