import { SourceFile } from "../tree"; import { PrettierConfigLoader } from "./format/prettier-config-loader"; import { ExecutionContext } from "../execution"; import { Marker } from "../markers"; /** * Options for project parsing. */ export interface ProjectParserOptions { /** * Optional execution context. */ ctx?: ExecutionContext; /** * Glob patterns to exclude from source file discovery. * Default excludes: node_modules, dist, build, .git, coverage, *.min.js, *.bundle.js */ exclusions?: string[]; /** * Whether to use git to discover files (respects .gitignore). * Default: true if in a git repository. */ useGit?: boolean; /** * Progress callback for file parsing. */ onProgress?: (phase: "discovering" | "parsing", current: number, total: number, filePath?: string) => void; /** * Whether to enable verbose logging. */ verbose?: boolean; /** * Optional predicate to filter which files should be parsed. * Called with the absolute file path after file discovery. * Return true to include the file, false to exclude it. * If not provided, all discovered files are parsed. */ fileFilter?: (absolutePath: string) => boolean; /** * Optional path to make source file paths relative to. * If not specified, paths are relative to projectPath. * Use this when parsing a subdirectory but wanting paths relative to the repository root. */ relativeTo?: string; } /** * Result of file discovery. */ export interface DiscoveredFiles { /** package.json files - parsed with PackageJsonParser for NodeResolutionResult */ packageJsonFiles: string[]; /** Lock files grouped by parser type */ lockFiles: { json: string[]; yaml: string[]; text: string[]; }; /** JavaScript/TypeScript files (includes .prettierrc.js, prettier.config.js) */ jsFiles: string[]; /** * JS/TS files that won't be parsed into an AST and are instead recorded as * Quarks (path only, no content). Currently only files over * {@link MAX_PARSEABLE_SIZE_BYTES}; other unparseable cases may join later. */ unparseableFiles: string[]; /** JSON files (tsconfig.json, .prettierrc.json, other .json) */ jsonFiles: string[]; /** YAML files (.prettierrc.yaml, other .yaml/.yml) */ yamlFiles: string[]; /** Plain text config files (.prettierignore, .gitignore, etc.) */ textFiles: string[]; } /** * Default exclusion patterns for file discovery. */ export declare const DEFAULT_EXCLUSIONS: string[]; /** * Exclusions that apply even to files git reports. Dependency trees and minified * bundles are sometimes committed but are never a project's own source, whereas the * remaining entries in {@link DEFAULT_EXCLUSIONS} are what a .gitignore already says. */ export declare const DEFAULT_TRACKED_EXCLUSIONS: string[]; /** * Parses an entire JavaScript/TypeScript project. * * This class handles: * - File discovery (source files, package.json, lock files) * - Prettier configuration detection (once per project) * - Parsing all files with appropriate parsers * - Sharing PrettierConfigLoader across all JavaScript parsers * * Can be used directly for CLI tools or wrapped by RPC handlers. */ export declare class ProjectParser { private readonly projectPath; private readonly relativeTo; private readonly exclusions; private readonly gitExclusions; private readonly ctx; private readonly useGit; private readonly onProgress?; private readonly verbose; private readonly fileFilter?; constructor(projectPath: string, options?: ProjectParserOptions); /** * Creates and initializes a PrettierConfigLoader for this project. * Use this when you need to handle Prettier detection separately from parsing. */ createPrettierLoader(): Promise; /** * Builds an Autodetect marker from the given source files. * Samples all files to detect common formatting styles. * Uses dynamic import to avoid circular dependencies. */ buildAutodetectMarker(sourceFiles: SourceFile[]): Promise; /** * Parses all source files in the project. * Yields source files as they are parsed. */ parse(): AsyncGenerator; /** * Discovers all files in the project that should be parsed. */ discoverFiles(): Promise; /** * Discovers files using git ls-files (respects .gitignore). */ private discoverFilesWithGit; /** * Discovers files by walking the directory tree. */ private discoverFilesWithWalk; /** * Checks if a file should be accepted for parsing. */ private isAcceptedFile; /** * Whether a source file exceeds {@link MAX_PARSEABLE_SIZE_BYTES}. A stat * failure returns false so the file follows the normal parse path (which * surfaces a real read error as a ParseError) rather than being quarked. */ private isOversize; /** * Classifies a yarn.lock file as YAML (Berry) or text (Classic). */ private classifyYarnLockFile; /** * Checks whether a git work tree encloses the project, which for a project below the * repository root is an ancestor directory. A linked work tree or submodule has `.git` * as a file, so presence rather than kind is what counts. */ private isGitRepository; /** * Counts total files to parse. */ private countFiles; /** * Applies the file filter to discovered files. */ private applyFileFilter; /** * Logs a message if verbose mode is enabled. */ private log; } //# sourceMappingURL=project-parser.d.ts.map