(node, depth, fieldName)
| 81 | }; |
| 82 | |
| 83 | function walk(node, depth, fieldName) { |
| 84 | if (node.isNamed) freq.set(node.type, (freq.get(node.type) || 0) + 1); |
| 85 | if ((node.isNamed || showAll) && depth <= maxDepth) { |
| 86 | const field = fieldName ? `${fieldName}: ` : ''; |
| 87 | const leaf = node.childCount === 0 ? ` "${snippet(node)}"` : ''; |
| 88 | console.log(`${' '.repeat(depth)}${field}${node.type} @${node.startPosition.row + 1}:${node.startPosition.column}${leaf}`); |
| 89 | } |
| 90 | for (let i = 0; i < node.childCount; i++) { |
| 91 | const child = node.child(i); |
| 92 | if (child) walk(child, depth + 1, node.fieldNameForChild(i)); |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | console.log(`\n# AST for ${sampleFile} (grammar: ${wasmPath.split('/').pop()})\n`); |
| 97 | walk(tree.rootNode, 0, null); |
no test coverage detected