/** * Workspace-level index that connects per-file symbol tables across imports. * * Caches FileSymbols per file, tracks the import dependency graph, and provides * lookup APIs for Go to Definition, Find References, Document Symbols, and * Diagnostics. Falls back to token-scanned definitions when the parser fails. */ import type { ParseError } from '../errors'; import type { FileSymbols, SymbolDef, SymbolRef } from './types'; export declare class WorkspaceIndex { private cache; /** Reverse import graph: file → set of files that import it */ private reverseImports; /** * Update the index for a single file. * Parses the file, builds the symbol table, and updates the import graph. * Returns the file symbols (or null if the file doesn't exist). */ updateFile(filePath: string, source?: string): FileSymbols | null; /** * Get file symbols, using cache if available. * Does NOT trigger a re-parse — call updateFile() first if the file may have changed. */ getFileSymbols(filePath: string): FileSymbols | null; /** * Get definitions for a file — returns AST definitions if available, * falls back to token-scanned definitions. */ getDefinitions(filePath: string): SymbolDef[]; /** * Find the definition of a symbol at a given position. * Searches the file's symbol table, then follows imports for cross-file resolution. */ findDefinition(filePath: string, line: number, column: number): SymbolDef | null; /** * Find all references to a symbol. * Searches the current file and all files that import it. */ findReferences(filePath: string, symbolName: string): SymbolRef[]; /** * Get the symbol name at a given position (could be a definition or reference site). * Returns the name and the definition it resolves to (if any). */ getSymbolAtPosition(filePath: string, line: number, column: number): { name: string; def: SymbolDef | null; } | null; /** * Find all locations of a symbol: the definition site + all reference sites. * Used by "Find All References" which should include the declaration. */ findAllOccurrences(filePath: string, symbolName: string): { file: string; line: number; column: number; nameLength: number; }[]; /** * Get top-level document symbols for the outline view. */ getDocumentSymbols(filePath: string): SymbolDef[]; /** * Get all symbols visible at a given position in a file. * Includes top-level definitions defined before the cursor, * plus definitions from all enclosing scope ranges. */ getSymbolsInScope(filePath: string, line: number, column: number): SymbolDef[]; /** * Get diagnostics for a file: parse errors + unresolved symbol references. */ getDiagnostics(filePath: string): { parseErrors: ParseError[]; unresolvedRefs: SymbolRef[]; }; /** * Invalidate a file and all files that depend on it. */ invalidateFile(filePath: string): void; private updateReverseImports; }