/** * Universal Tree-Sitter AST visitor. * * Walks a parsed syntax tree, applying the per-language {@link NodeQueries} * table, and produces an indexed symbol list. Ref emission (calls, type * references, imports, heritage) is intentionally out of scope here — it * ships on Day 4 alongside the C-family tests, where per-language fixtures * can verify each `callType` mapping. * * The visitor is O(n) over named children: each node is visited at most * once, and the scope stack is push/pop in O(1). The cost on a 50k-file * monorepo is dominated by `Parser.parse(content)` itself, which tree-sitter * implements as a single-pass GLR parse in WASM. * * Two design rules that shaped this module: * * 1. **Recursive scope tracking, not parent-chain walks.** `ts-parser.ts` * pushed scope parts onto an array and trimmed on return; we mirror * that. The cost is O(depth) push/pop instead of O(depth × symbols) * parent walks — for a 200-symbol file at depth 5, that's 1000 fewer * `parent` lookups. * * 2. **Identifier extraction has two shapes.** Most languages give you a * `name` field on the declaration node; a handful (C declarators, * Elixir calls) don't. The visitor tries `queries.nameExtractor` first, * then falls back to `queries.nameField[type] ?? 'name'`, then gives * up — emitting no symbol for that node rather than fabricating one. */ import type { Tree } from 'web-tree-sitter'; import type { Symbol as IndexSymbol, Ref, SymbolLang } from '../schema.js'; import type { NodeQueries } from './queries.js'; /** Result of walking one parsed file. */ interface VisitResult { symbols: IndexSymbol[]; refs: Ref[]; } /** * Walk a parsed tree and emit symbols. * * `tree` — the parsed syntax tree. * `content` — original source text. Used to derive `signature` (the * declaration node's slice of the source) and `docComment`. * `file` — absolute path, threaded into every emitted symbol. * `lang` — the language the tree was parsed under. * `queries` — per-language node-mapping table. */ export declare function visitTree(tree: Tree, content: string, file: string, lang: SymbolLang, queries: NodeQueries): VisitResult; export {}; //# sourceMappingURL=visitor.d.ts.map