如何将Codelens提供商与参考提供商链接到代码API

发布于 2025-01-18 17:30:47 字数 518 浏览 3 评论 0原文

我已经有一个自定义语言的现有参考提供商。它有效,它使用参考文献打开参考,然后转到eek:转到参考

尽管,我不使用这些命令editor.actor.action.peeklocations或editor.actor.action.showReferences for参考提供商,所有内容都是由VS Code API自动管理的,我们只需要实现ProvidEreFerences并返回位置和URI即可。

现在,我想对Codelens提供商进行与TypeCript完成的操作,即单击引用时,它打开了一个窥视窗口。 : 代码镜头参考

我已经提供 是否有一种方法可以直接链接该密码和参考提供商,因此单击引用相同的引用时?

I already have an existing reference provider for the custom language. It works, it opens a references using go to references and go to peek: Go to references

Although, I am not using these commands editor.action.peekLocations or editor.action.showReferences for the reference provider and everything is automatically managed by VS Code API, we just need to implement provideReferences and return location and uri.

Now, I want to do the same with codelens provider as done for typecript, i.e., on clicking on references, it opens a peek window. :
Code lens references

I have provide
Is there a way, to directly link this codelens and reference provider, so on clicking on the references it does the same?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

断念 2025-01-25 17:30:47

找到答案,我们必须使用VS-Code内置命令的“ editor.action.showreferences”命令。参考Vscode的GitHub仓库: https://github.com/microsoft/vscode/blob/main/main/extensions/typescript-language-features/src/languagefeatures/codelens/basecodelens/basecodelensprovider.ts

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

Found the answer, We have to use "editor.action.showReferences" command from VS- Code built-in commands. Reference from the github repo of vscode: 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]
                };
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文