语言服务器协议:获取内部函数/类的符号信息 [英] Language Server Protocol: Get Symbol Information of inner functions/classes
问题描述
我正在 VSCode 中搜索一个命令(a la vscode.commands.executeCommand(...)
),该命令返回函数/类的内部函数/类的符号信息(大纲).
I'm searching for a command in VSCode (a la vscode.commands.executeCommand(...)
) that returns symbol information (outline) of inner functions/classes of a function/class.
类似的命令vscode.commands.executeCommand('vscode.??', Range(2,6))
on
1 def foo1():
2 def innerfoo():
3 print("hello")
4 def innerfoo2():
5 print("world)
6 innerfoo()
应该返回一个带有 innerfoo
和 innerfoo2
的数组.
should return an array with innerfoo
and innerfoo2
.
命令 vscode.commands.executeCommand('vscode.executeDocumentSymbolProvider')
将提供整个文档的第一级符号信息.例如.在
The command vscode.commands.executeCommand('vscode.executeDocumentSymbolProvider')
will provide 1st-level symbol information for the whole document.
E.g. in
class MyClass:
def foo(self):
pass
只找到MyClass
推荐答案
此信息隐藏在 DocumentSymbol
的 children
属性中(返回通过 vscode.executeDocumentSymbolProvider
):
This information is hidden inside the children
property of DocumentSymbol
(returned by vscode.executeDocumentSymbolProvider
):
let symbols = vscode.commands.executeCommand ('vscode.executeDocumentSymbolProvider');
console.log (symbols[0].children);
我写'隐藏'是因为children
不显示,如果你在上面的代码中简单地运行console.log (symbols);
.
I write 'hidden' because children
does not show, if you simply run console.log (symbols);
in the above code.
这篇关于语言服务器协议:获取内部函数/类的符号信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!