有没有办法从我的VSCODE扩展语言函数中找到文本范围?

发布于 2025-01-27 18:56:41 字数 560 浏览 4 评论 0原文

我正在使用typescript-language-features来创建VSCODE语言扩展。作为该扩展名的一部分,我想注册一个悬停提供商(使用 vscode.languages.RegisterHoverProvider )提供语法帮助。

我怀疑选择上下文相关建议的最佳方法是评估当前光标下文的文本范围。该范围可用于我的提供商吗?如果是这样,您可以建议一种访问它的方法吗?

谢谢!

I am authoring a VSCode language extension using the typescript-language-features. As part of that extension, I'd like to register a hover provider (using vscode.languages.registerHoverProvider) that offers syntax help.

I suspect that the best way to select context-relative suggestions is to evaluate the current textmate scope of the text under the cursor. Is that scope available to my providers? If so, can you suggest a method for accessing it?

Thanks!

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

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

发布评论

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

评论(1

情绪 2025-02-03 18:56:42

不,您的假设是错误的。 TextMate-Scope(如您所谓的)是针对某些字母组合的示波器ID的简单,基于正则的分配。对于诸如代码提示或代码完成之类的内容,它根本无济于事。

取而代之的是,您必须为要支持的语言编写自己的解析器,从而为给定位置提供精确的符号信息。然后,这可以用于派发代码提示和其他信息。

No, your assumption is wrong. The textmate-scope (as you call it) is a simple, regex-based assignment of a scope ID for certain letter combinations. It doesn't help at all for things like code hints or code completion.

Instead you have to write your own parser for the language you want to support, which in turn can give you precise symbol information for a given position. This can then be used to derive code hints and other information.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文