import type Database from 'better-sqlite3'; import type { IIndexWriter } from '../db/schema.js'; import type { ParsedFile } from '../parser/ast-parser.js'; /** * Shared reference resolution utilities used by both parse.ts and incremental-indexer.ts. * Extracted to eliminate duplication of re-export chain following and symbol resolution logic. */ /** * Follow re-export chains to find the original definition. * When a module re-exports a symbol from another module, this traces through * the chain to find where the symbol is actually defined. * * When a file isn't in the parsedFiles map (unchanged file not re-parsed), * falls back to querying the imports table in the DB. * * @param symbolName - Symbol name to look up * @param filePath - Absolute path to start search * @param parsedFiles - Map of parsed files (in-memory) * @param definitionMap - Map of file paths to exported definition IDs * @param visited - Set of visited paths (cycle detection) * @param conn - Optional database connection for fallback (when file not in parsedFiles) * @param fileIdMap - Optional map of file paths to IDs (for DB fallback) * @returns Definition ID if found, null otherwise */ export declare function followReExportChain(symbolName: string, filePath: string, parsedFiles: Map, definitionMap: Map>, visited: Set, conn?: Database.Database, fileIdMap?: Map): number | null; /** * Resolve a symbol to its definition ID, handling default imports specially. * Extracts the repeated pattern from parse.ts and incremental-indexer.ts. * * @param sym - Symbol to resolve * @param ref - Reference containing the symbol * @param definitionMap - Map of file paths to exported definition IDs * @param fileIdMap - Map of file paths to file IDs * @param db - Database interface for definition lookups * @returns Definition ID if found, null otherwise */ export declare function resolveSymbolToDefinition(sym: { name: string; kind: string; localName: string; }, ref: { resolvedPath?: string | null; isExternal: boolean; }, definitionMap: Map>, fileIdMap: Map, db: { getDefinitionByName: (fileId: number, name: string) => number | null; }): number | null; /** * Insert references, symbols, and usages for a single parsed file. * Mirrors the logic in parse.ts indexParsedFiles pass 2. * * @param parsed - Parsed file data * @param fromFileId - File ID in database * @param db - Database interface * @param fileIdMap - Map of file paths to file IDs * @param definitionMap - Map of file paths to exported definition IDs * @param allParsedFiles - All parsed files (for re-export resolution) * @param conn - Database connection (for DB fallback in re-export chains) */ export declare function insertFileReferences(parsed: ParsedFile, fromFileId: number, db: IIndexWriter, fileIdMap: Map, definitionMap: Map>, allParsedFiles: Map, conn: Database.Database): void; /** * Insert internal usages (same-file calls) for a single parsed file. * Mirrors the logic in parse.ts indexParsedFiles pass 3. * * @param parsed - Parsed file data * @param fileId - File ID in database * @param filePath - Absolute path to the file (key for allDefinitionMap) * @param allDefinitionMap - Map of file paths to all (not just exported) definition IDs * @param db - Database interface */ export declare function insertInternalUsages(parsed: ParsedFile, fileId: number, filePath: string, allDefinitionMap: Map>, db: IIndexWriter): void; /** * Delete all imports, symbols, and usages originating from a file. * Used during incremental sync when a file is modified. * * @param conn - Database connection * @param fileId - File ID to clean up */ export declare function deleteFileImportsAndSymbols(conn: Database.Database, fileId: number): void; //# sourceMappingURL=reference-resolver.d.ts.map