(node: TSNodeLike)
| 66 | const lines = content.split('\n'); |
| 67 | const issues: SyntaxIssue[] = []; |
| 68 | const visit = (node: TSNodeLike): void => { |
| 69 | if (issues.length >= MAX_REPORTED_ISSUES) return; |
| 70 | // Prune: only descend where an error lives (real tree-sitter sets hasError |
| 71 | // on every ancestor of an ERROR/MISSING node). Mocks may omit it → descend. |
| 72 | if (node.hasError !== undefined && !boolProp(node.hasError, node)) return; |
| 73 | const missing = boolProp(node.isMissing, node); |
| 74 | if (node.type === 'ERROR' || missing) { |
| 75 | const line = node.startPosition.row + 1; |
| 76 | issues.push({ |
| 77 | line, |
| 78 | excerpt: (lines[node.startPosition.row] ?? '').trim().slice(0, 120), |
| 79 | kind: missing ? 'missing' : 'error', |
| 80 | }); |
| 81 | if (node.type === 'ERROR') return; // children of an ERROR node are noise |
| 82 | } |
| 83 | for (let i = 0; i < node.childCount; i++) { |
| 84 | const c = node.child(i); |
| 85 | if (c) visit(c); |
| 86 | } |
| 87 | }; |
| 88 | visit(root); |
| 89 | return issues; |
| 90 | } |
no test coverage detected