(node: TSNode, type: string)
| 19 | * Query all nodes of a specific type in the AST |
| 20 | */ |
| 21 | export function queryNodes(node: TSNode, type: string): TSNode[] { |
| 22 | const results: TSNode[] = []; |
| 23 | |
| 24 | function traverse(n: TSNode) { |
| 25 | if (n.type === type) { |
| 26 | results.push(n); |
| 27 | } |
| 28 | for (const child of n.children) { |
| 29 | if (!child) {continue;} |
| 30 | traverse(child); |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | traverse(node); |
| 35 | return results; |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * Get base classes from a class definition node |
no test coverage detected