繁体   English   中英

如何将 Codelens 提供者与 VS Code 的参考提供者联系起来 API

[英]How to link Codelens provider with reference provider for VS Code API

我已经有自定义语言的现有参考提供者。 它有效,它使用 go 和 go 打开引用以查看: Go 到引用

虽然,我没有为引用提供者使用这些命令 editor.action.peekLocations 或 editor.action.showReferences 并且一切都由 VS Code API 自动管理,我们只需要实现 provideReferences 并返回位置和 uri。

现在,我想对 codelens 提供程序执行与 typecript 相同的操作,即在单击参考时,它会打开一个 peek window。:代码镜头参考

我提供了有没有一种方法可以直接链接这个代码镜头和参考提供者,所以在点击参考时它会做同样的事情吗?

找到了答案,我们必须使用 VS-Code 内置命令中的“editor.action.showReferences”命令。 参考自 vscode 的 github repo: https://github.com/microsoft/vscode/blob/main/extensions/typescript-language-features/src/languageFeatures/codeLens/baseCodeLensProvider.ts

lens.command = {
                    title: "References",
                    tooltip: "References",
                    command: "editor.action.showReferences",
                    arguments: [document.uri, lens.range.start, lens.location]
                };

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM