import { Lang } from "@ast-grep/napi"; import { type WasmLang } from "./tree-sitter-wasm.js"; /** A language key: an `@ast-grep/napi` built-in, or one of the WASM grammars. */ type LangKey = Lang | WasmLang; /** * Whether this file's language can be parsed HERE, and if not, which of the two reasons. * * 🔴 THE THREE CASES ARE SEPARATE MEMBERS BECAUSE THEY ARE SEPARATE FACTS. "Extension not in * the table" and "the language IS ours but its grammar failed to load in this process" must not * share one `null`: both callers would print the first sentence, and a check that did not run * would read as a verdict. With WASM grammars shipped as a regular dependency there is no * install or platform gap left, so `grammar-load-failed` should not happen — but if the runtime * genuinely cannot load, the report carries the loader's own error text, never "not defined" * and never an install instruction the user cannot act on. */ export type LangSupport = { readonly kind: "ready"; readonly lang: LangKey; } | { readonly kind: "grammar-load-failed"; readonly lang: WasmLang; readonly error: string; } | { readonly kind: "unsupported"; }; export declare function langForFile(file: string): Promise; /** The one sentence both callers print for a symbol reference that could not be checked. */ export declare function notCheckedReason(support: Extract): string; /** A symbol definition found in a file. */ export interface SymbolDef { /** The defined identifier, e.g. "parseConfig". */ readonly name: string; /** The tree-sitter node kind, e.g. "function_declaration" (raw, per-grammar). */ readonly kind: string; /** Enclosing class/module name, or "" at top level. */ readonly scope: string; /** 1-based line of the definition. */ readonly line: number; } /** * Extract the symbols defined in a single file's source. Async because the Python / Ruby / Rust * grammars are WebAssembly, whose instantiation is async; the napi languages resolve at once. */ export declare function definedSymbols(code: string, lang: LangKey): Promise; /** Defined symbols for a file on disk, or [] if unreadable/unsupported. */ export declare function definedSymbolsInFile(file: string): Promise; /** * Whether `file` defines a top-level (or scoped) symbol named `name`. This is * the whole check for a file-qualified reference (`path#symbol`): we parse the * one named file — no project-wide index, no resolution across files. As a * fallback we also consult a co-located declaration file (`.rbi` / `.d.ts`), so * typed dynamic symbols resolve without running Sorbet / the TS compiler. */ export declare function fileDefinesSymbol(file: string, name: string): Promise; export {}; //# sourceMappingURL=symbols.d.ts.map