import { SourceFile } from 'ts-morph'; import { ModuleCache } from '../core/ModuleCache'; import type { ImportStatement, ExportStatement, ParsedModule } from './types'; export type { ImportStatement, ExportStatement, ExternalCall, SourceLocation, InheritanceInfo, ModuleMetrics, ModuleMetadata, ParsedModule, } from './types'; /** * ASTParser class handles parsing of TypeScript/JavaScript files * using the TypeScript Compiler API */ export declare class ASTParser { private rootDir; private cache?; private static project; /** * Memoised module resolution, per instance: the cache is keyed by a * project-relative path, so sharing it across parsers with different roots * would return files from the wrong project. */ private resolutionCache; constructor(rootDir: string, cache?: ModuleCache); /** * Gets or initializes the ts-morph project singleton */ private getProject; /** * Parses a TypeScript/JavaScript file and extracts structural information * @param filePath - Relative or absolute path to the file * @returns Promise - Parsed module information */ parse(filePath: string): Promise; extractImports(sourceFile: SourceFile, filePath: string): ImportStatement[]; extractExports(sourceFile: SourceFile): ExportStatement[]; private detectExternalCalls; private extractMetadata; /** * A barrel re-exports other modules and declares nothing itself. Detected * structurally rather than by filename: plenty of index.ts files hold real * code, and plenty of barrels are not called index.ts. */ private detectBarrel; private extractInheritance; private extractDecorators; private calculateMetrics; /** * Determines if a module is external (from node_modules) * @param source - Import source string * @returns boolean - True if external module */ private isExternalModule; /** * Resolves a relative import to an absolute path * @param source - Relative import path * @param currentFilePath - Path of the file containing the import * @returns string - Resolved absolute path */ private resolveRelativeImport; /** * Finds which file an extensionless import actually refers to. * * This used to append '.ts' unconditionally, so every import of a .tsx file — * that is, every React component — resolved to a path that did not exist, and * the dependency was dropped from the graph without a word. A UI-heavy * project had almost no edges and still scored 100. * * Order follows TypeScript's own preference; the directory forms cover * `import x from './components'` resolving to its index file. * * @returns the project-relative path that exists, or undefined */ private probeExtensions; } //# sourceMappingURL=ASTParser.d.ts.map