export class ProjectContextManager {
    constructor(workspaceRoot) {
        this.symbols = {};
        this.imports = {};
        this.callSites = {};
        this.indexers = new Map();
        this.resolvers = new Map();
        this.workspaceRoot = workspaceRoot;
    }
    getIndexer(language) {
        return this.indexers.get(language);
    }
    registerIndexer(indexer) {
        this.indexers.set(indexer.language, indexer);
    }
    registerResolver(resolver) {
        this.resolvers.set(resolver.language, resolver);
    }
    addExports(language, exports) {
        for (const exp of exports) {
            if (!this.symbols[exp.name]) {
                this.symbols[exp.name] = [];
            }
            this.symbols[exp.name].push(exp);
        }
    }
    addImports(filePath, imports) {
        this.imports[filePath] = imports;
    }
    addCallSite(funcName, filePath, argPositions) {
        if (!this.callSites[funcName]) {
            this.callSites[funcName] = [];
        }
        this.callSites[funcName].push({ filePath, argPositions });
    }
    /**
     * Resolves a local variable name in a file to its actual source definition.
     */
    resolveDefinition(localName, filePath, language) {
        const fileImports = this.imports[filePath];
        if (!fileImports || !fileImports[localName]) {
            // Not an imported symbol, might be local or global - but for cross-file we look for imports
            return null;
        }
        const sourcePath = fileImports[localName];
        const resolver = this.resolvers.get(language);
        if (!resolver)
            return null;
        const absoluteSourcePath = resolver.resolveImport(sourcePath, filePath, this.workspaceRoot);
        if (!absoluteSourcePath)
            return null;
        // Now find the symbol in the source path
        const potentialSymbols = this.symbols[localName]; // This is a bit simplified; needs to handle 'import { x as y }'
        if (!potentialSymbols)
            return null;
        return potentialSymbols.find(s => s.filePath === absoluteSourcePath) || null;
    }
}
//# sourceMappingURL=project-context-manager.js.map