/** * Tree-Sitter WASM Universal AST Extractor (Phase 1). * * Replaces regex heuristics in `generic-parser.ts` for languages with a * pre-compiled tree-sitter grammar: C, C++, Java, C#, PHP, Ruby, Swift, * Kotlin, Elixir, Shell (bash), plus Go/Python/Rust as opt-in WASM paths * (default behavior still uses the existing first-class parsers). * * The runtime contract matches {@link parseGeneric}: callers receive a * {@link FileSymbols} record. Symbol ids are always 0 — the caller assigns * them during bulk insertion. Refs carry `fromId: 0` and are deduplicated * downstream by `parser-dispatch.ts#withRelations`. * * Design notes: * - Grammar WASM files live alongside the runtime in `wasm//`. * Vendoring them in-tree makes builds deterministic; no fetch-on-first-run. * - The {@link web-tree-sitter} runtime is initialized once per process. * `Language.load(wasmPath)` resolves on the first parse of each language * and is memoized — every subsequent parse reuses the same Language object. * - On any failure (grammar file missing, runtime not installed, parse error * with no recoverable symbols) this module returns an empty `symbols[]` * rather than throwing — matching the existing parsers' "never drops a * file from the index" contract. */ import type { FileSymbols, SymbolLang } from './schema.js'; /** Visible for tests: the absolute path to a vendored grammar WASM. */ export declare function getGrammarWasmPath(lang: SymbolLang): string | undefined; /** * Async entry point mirroring {@link parseGeneric}. Used by * `parser-dispatch.ts` via dynamic import. Returns an empty `symbols[]` * on any failure rather than throwing — the dispatch layer falls back to * `generic-parser` for regex coverage when this returns zero symbols. * * Symbol emission is *not* implemented in this file yet — this Day-1 * scaffold only proves grammar loading and parsing work end-to-end. * Day 2-3 introduces the universal visitor (`tree-sitter/visitor.ts`) * and per-language query tables (`tree-sitter/queries.ts`). */ export declare function parseSymbols(opts: { file: string; content: string; lang: SymbolLang; }): Promise; /** * Internal helper used by AST-shape inspectors and tests. Loads and caches * the tree-sitter `Language` for a given {@link SymbolLang} without parsing. * Not part of the public parser API — the indexer should always go through * {@link parseSymbols}. */ export declare function loadTreeSitterLanguage(lang: SymbolLang): Promise; /** Test-only helper: parse and return the root node type. Throws on failure. */ export declare function __smokeRootType(opts: { content: string; lang: SymbolLang; }): Promise; /** * Parse source code using Tree-Sitter and return the AST and parser. * Caller MUST call `tree.delete()` and `parser.delete()` in a finally block. */ export declare function parseTreeSitterAst(opts: { content: string; lang: SymbolLang; }): Promise<{ tree: import('web-tree-sitter').Tree; parser: import('web-tree-sitter').Parser; } | null>; /** * The identifier a tree-sitter declaration is named by. C/C++ nest it in a * declarator chain (`function_definition` → `function_declarator` → * `identifier`); comparing or reporting the OUTER declarator's text yields * `add(int a, int b)` instead of `add`. */ export declare function treeSitterDeclarationName(node: import('web-tree-sitter').Node): string | undefined; //# sourceMappingURL=tree-sitter-parser.d.ts.map