()
| 769 | |
| 770 | |
| 771 | export async function getDocumentSymbols(): Promise<Array<vs.DocumentSymbol & { parent: vs.DocumentSymbol | undefined }> | undefined> { |
| 772 | const documentSymbolResult = await vs.commands.executeCommand<vs.DocumentSymbol[]>("vscode.executeDocumentSymbolProvider", currentDoc().uri); |
| 773 | if (!documentSymbolResult?.length) |
| 774 | return undefined; |
| 775 | |
| 776 | // Return a flattened list with references to parent for simplified testing. |
| 777 | const resultWithEmptyParents = documentSymbolResult.map((c) => Object.assign(c, { parent: undefined as vs.DocumentSymbol | undefined })); |
| 778 | return resultWithEmptyParents.concat(flatMap( |
| 779 | documentSymbolResult, |
| 780 | (s) => s.children ? s.children.map((c) => Object.assign(c, { parent: s })) : [], |
| 781 | )); |
| 782 | } |
| 783 | |
| 784 | async function getDefinitions(position: vs.Position): Promise<Array<vs.Location | vs.DefinitionLink>> { |
| 785 | const definitionResult = await vs.commands.executeCommand<Array<vs.Location | vs.DefinitionLink>>("vscode.executeDefinitionProvider", currentDoc().uri, position); |
no test coverage detected