0
votes

I'm writing an extension for vscode in typescript.

At some point I need to find all symbols declared in a document (the document contains typescript code).

I'm using the built-in command "vscode.executeDocumentSymbolProvider" for that. But it returns only types and variables, ie, symbols declared with the keywords class, interface, const, let...etc. It doesn't return for example a parameter of a function. Is there a reason for that ? I thought even parameters were symbols since a parameter can, for example, shadow a varaible declared in an outer scope. Also, Is there another way to find all the symbols ?

1

1 Answers

1
votes

Since I figured it out I'll post an answer in case someone needs it in the future.

The command "vscode.executeDocumentSymbolProvider" does in fact return all the symbols. It's just that they are nested inside each others (tree like structure). See the "children" property of "vscode.DocumentSymbol" class.