Reputation: 3487
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.
A command like
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()
should return an array with innerfoo
and innerfoo2
.
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
only MyClass
is found
Upvotes: 1
Views: 921
Reputation: 3487
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);
I write 'hidden' because children
does not show, if you simply run console.log (symbols);
in the above code.
Upvotes: 1
Reputation: 53357
There's no API like that. Language support is self contained and usually does not provide its information to the outer world.
You would instead have to create your own parser, which processes the code to find symbol information.
Upvotes: 0