/** * ImportResolverBridge — cross-language import resolution for call graph enrichment. * * Builds a per-file map of { localName → resolvedSourceFilePath } so that Pass 2 * of CallGraphBuilder.build() can prefer the imported file when multiple candidates * share the same function name. * * TypeScript / JavaScript / Python are handled via import-parser.ts (existing). * Go, Rust, Ruby, Java get lightweight regex parsers here. */ import type { FileAnalysis } from './import-parser.js'; /** filePath → Map */ export type ImportMap = Map>; /** * Build an ImportMap from in-memory file sources, for base-class resolution inside * CallGraphBuilder.build() (Pass 7, buildClassNodes). When a class extends a base whose * simple name is also declared elsewhere, the import the child actually wrote is the * decisive evidence for which declaration is the real base — it must outrank the * same-directory / global-unique fallbacks, otherwise a same-named class in the child's * own directory is wired as a false base (a precision regression, since CHA's stated bias * is false-negatives over false-positives). * * Unlike {@link buildImportMap} (which absolutizes the source via resolve() and so can * never prefix-match the repo-relative filePaths the call graph keys on), this preserves * the caller's path style with a posix join+normalize, yielding an extensionless, * repo-relative target (e.g. `widgets/sphere.ts` importing `../shapes/base` → `shapes/base`) * that prefix-matches the class node's `shapes/base.ts`. * * Scope: relative TS/JS/Python imports — the languages with a content-level import parser. * Non-relative (package) imports and other languages are skipped; resolution then falls * through to the same-directory / global-unique layers exactly as before (additive — this * can only recover a correct base, never introduce a new wrong one). */ /** * Languages whose relative imports {@link buildBaseImportMap} actually resolves into the * `confidence: 'import'` edge path (the live import-resolution pipeline). Authoritative * source for the `imports` capability flag in the declarative language-support registry * (change: add-declarative-language-support-registry). MUST match the dispatch in * {@link buildBaseImportMap} below. (Go/Rust/Ruby/Java parsers exist elsewhere but are not * wired into this live path, so the registry does not claim `imports` for them — honesty * over latent capability.) */ export declare const IMPORT_RESOLUTION_LANGUAGES: ReadonlySet; export declare function buildBaseImportMap(files: Array<{ path: string; content: string; language: string; }>): ImportMap; /** * Resolve a Python leading-dot relative import to an extensionless, repo-relative * module path. `from .impl import x` in `pkg/caller.py` → `pkg/impl`; * `from ..util.mod import y` in `pkg/sub/caller.py` → `pkg/util/mod`; * `from . import x` → the caller's package directory. N leading dots = N package * levels (1 = the current package), the remainder is a dotted module path. */ export declare function resolvePythonRelative(callerDir: string, source: string): string; /** * A re-export-aware import map: like {@link buildBaseImportMap}, but a `localName` * imported from a barrel that re-exports it (`export { x } from './impl'`, * `export * from './impl'`, depth-N chains) resolves to the **true definition * module**, not the barrel — so a call through any depth of barrel resolves to the * real target instead of stalling at the index and falling through to the * ambiguous name-only fallback (change: add-call-resolution-recall, item 1). * * `reExported` records every `${callerFile}\0${localName}` whose resolution crossed * ≥1 re-export hop, so the call-graph builder can label that edge with the * `re_export` provenance confidence (honesty: a barrel-crossed edge is still a * proven concrete target, but the consumer can see it was resolved through a * re-export rather than a direct import). * * Strict superset of {@link buildBaseImportMap}: when no re-export chain applies * (the common case), the resolved module is byte-identical to the direct import * target, so non-barrel behaviour — and the regression gate over directly-resolved * edges — is preserved exactly. Re-export *chasing* is TypeScript/JavaScript only * (the languages with an export parser that detects re-exports); Python relative * imports still resolve directly (no `__init__` re-export chasing — deferred). */ export interface ResolvedImportMap { map: ImportMap; reExported: Set; } export declare function buildResolvedImportMap(files: Array<{ path: string; content: string; language: string; }>): ResolvedImportMap; /** A module's on-disk identity + source, as resolved from a relative specifier. */ export interface ResolvedModuleSource { path: string; content: string; language: string; } /** * Collect the re-export **barrel** files reachable from `seeds` by following their * relative imports and re-export sources, so an INCREMENTAL build over a file subset * can resolve barrel-imported calls the same way a full build does * (change: add-call-resolution-recall). An incremental subset is `{ changed file + * its callers }`; a barrel an index re-exports through is neither, so without this it * is absent and `buildResolvedImportMap` cannot follow the chain — the call silently * degrades from `re_export`/`import` to `name_only`, breaking incremental↔full parity. * * Only files that *themselves re-export* are returned: a leaf definition file at a * chain's end is not needed (resolveDef returns its module from the chain without its * content, and the call-graph trie resolves the node). `readModule(spec, fromFile)` * resolves a relative specifier to a module source, or undefined when it is a package * or cannot be read. Bounded by re-export depth and a file cap (fail-soft: beyond the * cap, those edges degrade rather than the build hanging). */ export declare function collectReExportBarrels(seeds: Array<{ path: string; content: string; language: string; }>, readModule: (spec: string, fromFile: string) => Promise, options?: { maxFiles?: number; }): Promise; /** Build an ImportMap from TS/JS/Python FileAnalysis objects (from import-parser). */ export declare function buildImportMap(analyses: FileAnalysis[]): ImportMap; /** * Given a caller file and a callee name, return the source file the name was * imported from (if known), or undefined. */ export declare function findCalleeFileViaImport(importMap: ImportMap, callerFilePath: string, calleeName: string): string | undefined; export declare function parseGoImports(filePath: string, content: string, allFilePaths: string[]): Map; export declare function parseRustImports(_filePath: string, content: string, allFilePaths: string[]): Map; export declare function parseRubyImports(filePath: string, content: string, allFilePaths: string[]): Map; export declare function parseJavaImports(content: string, allFilePaths: string[]): Map; //# sourceMappingURL=import-resolver-bridge.d.ts.map