[英]How to tokenize grammars, like in monaco.editor.tokenize for use in extension
It doesn't seem like there's an official way of doing this right now. 似乎目前尚无正式的方法来执行此操作。 There is an open feature request for adding the ability to retrieve tmLanguage scopes at a position here: #580
有一个开放的功能要求,可以在以下位置添加检索tmLanguage范围的功能: #580
There is one potential workaround, which requires adding a dependency to the scope-info extension. 有一种可能的解决方法,它要求向scope-info扩展添加依赖项。 This extension exposes an API of its own that other extension can use.
此扩展公开了其他扩展可以使用的自己的API。 Here's a code example posted by the author in the linked issue:
这是作者在链接的问题中发布的代码示例:
import * as api from 'scope-info'
async function example(doc : vscode.TextDocument, pos: vscode.Position) {
const siExt = vscode.extensions.getExtension<api.ScopeInfoAPI>('siegebell.scope-info');
const si = await siExt.activate();
const t1 : api.Token = si.getScopeAt(doc, pos);
}
Update: unfortunately, it looks like scope-info is no longer compatible with current VSCode versions . 更新:不幸的是,看起来scope-info 不再与当前VSCode版本兼容 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.