( dap: Dap.TestApi, variable: Dap.Variable, walker: (v: Dap.Variable, depth: number) => Promise<boolean> | boolean, depth = 0, format?: Dap.ValueFormat, )
| 20 | * first-search until walker returns false. |
| 21 | */ |
| 22 | export const walkVariables = async ( |
| 23 | dap: Dap.TestApi, |
| 24 | variable: Dap.Variable, |
| 25 | walker: (v: Dap.Variable, depth: number) => Promise<boolean> | boolean, |
| 26 | depth = 0, |
| 27 | format?: Dap.ValueFormat, |
| 28 | ): Promise<void> => { |
| 29 | if (!(await walker(variable, depth))) { |
| 30 | return; |
| 31 | } |
| 32 | |
| 33 | if (variable.variablesReference === undefined) { |
| 34 | return; |
| 35 | } |
| 36 | |
| 37 | const hasHints = typeof variable.namedVariables === 'number' |
| 38 | || typeof variable.indexedVariables === 'number'; |
| 39 | if (hasHints) { |
| 40 | if (variable.namedVariables) { |
| 41 | const named = await dap.variables({ |
| 42 | variablesReference: variable.variablesReference, |
| 43 | filter: 'named', |
| 44 | format, |
| 45 | }); |
| 46 | for (const variable of named.variables) { |
| 47 | await walkVariables(dap, variable, walker, depth + 1, format); |
| 48 | } |
| 49 | } |
| 50 | if (variable.indexedVariables) { |
| 51 | const indexed = await dap.variables({ |
| 52 | variablesReference: variable.variablesReference, |
| 53 | filter: 'indexed', |
| 54 | start: 0, |
| 55 | count: variable.indexedVariables, |
| 56 | format, |
| 57 | }); |
| 58 | for (const variable of indexed.variables) { |
| 59 | await walkVariables(dap, variable, walker, depth + 1); |
| 60 | } |
| 61 | } |
| 62 | } else { |
| 63 | const all = await dap.variables({ |
| 64 | variablesReference: variable.variablesReference, |
| 65 | format, |
| 66 | }); |
| 67 | for (const variable of all.variables) { |
| 68 | await walkVariables(dap, variable, walker, depth + 1, format); |
| 69 | } |
| 70 | } |
| 71 | }; |
| 72 | |
| 73 | export class Logger { |
| 74 | private _dap: Dap.TestApi; |
no test coverage detected