我试图为visual studio代码创建一个扩展,它需要在类似于下面链接的图像中显示的引用的文件中注释行的能力。

我希望能够在不修改源代码文件的情况下添加注释,例如红色矩形中显示的注释。我希望能够这样做的每一行源文件。我还希望能够对注释的内容进行动态修改。
我已经搜索了VSC的文件以及其他地方。我还没找到呢。有人能引导我朝正确的方向走吗?
我知道以下内容是不正确的,但我不知道还应该在哪里检查它应该如何完成。
class TestCodeLensProvider implements vscode.CodeLensProvider {
public provideCodeLenses(document: TextDocument, token: CancellationToken):
CodeLens[] | Thenable<CodeLens[]> {
return new Array<CodeLens>();
}
public resolveCodeLens?(codeLens: CodeLens, token: CancellationToken):
CodeLens | Thenable<CodeLens> {
return new CodeLens(new vscode.Range(new vscode.Position(1, 1), new vscode.Position(1, 2)),/*I also don't know how to specify my command here*/ );
}
}
export function activate(ctx: vscode.ExtensionContext): void {
ctx.subscriptions.push(
vscode.languages.registerCodeLensProvider(
'json', new TestCodeLensProvider()));发布于 2018-05-26 07:53:20
你的截图中的功能叫做“代码镜头”。更具体地说,您正在寻找registerCodeLensProvider()函数的 namespace。或者,如果您正在编写语言服务器而不是直接使用VSCode API,则为 request method。
https://stackoverflow.com/questions/50537474
复制相似问题