简体   繁体   English

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

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

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它有效,它使用 go 和 go 打开引用以查看: Go 到引用

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

Now, I want to do the same with codelens provider as done for typecript, ie, on clicking on references, it opens a peek window. : Code lens references现在,我想对 codelens 提供程序执行与 typecript 相同的操作,即在单击参考时,它会打开一个 peek window。:代码镜头参考

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

Found the answer, We have to use "editor.action.showReferences" command from VS- Code built-in commands.找到了答案,我们必须使用 VS-Code 内置命令中的“editor.action.showReferences”命令。 Reference from the github repo of vscode: https://github.com/microsoft/vscode/blob/main/extensions/typescript-language-features/src/languageFeatures/codeLens/baseCodeLensProvider.ts参考自 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