# ParserOrchestrator

**Kind:** Class

**Source:** [`atloria-monorepo/libs/parser-core/src/orchestrator/parser-orchestrator.ts`](https://github.com/sherkety/atloria/blob/main/atloria-monorepo/libs/parser-core/src/orchestrator/parser-orchestrator.ts#L75)

ParserOrchestrator - Coordinates multiple parsers for project-wide parsing

## Methods

| Method | Signature | Returns |
|---|---|---|
| `initialize` | `initialize(parserConfig: ParserConfig)` | `Promise<void>` |
| `registerParser` | `registerParser(parser: IParser, priority: undefined)` | `void` |
| `unregisterParser` | `unregisterParser(name: string)` | `boolean` |
| `getParser` | `getParser(name: string)` | `IParser | undefined` |
| `getRegisteredParsers` | `getRegisteredParsers()` | `string[]` |
| `findParserForFile` | `findParserForFile(filePath: string)` | `string | null` |
| `findAllParsersForFile` | `findAllParsersForFile(filePath: string)` | `string[]` |
| `parseFile` | `parseFile(filePath: string, content: string)` | `Promise<ParseResult>` |
| `parseFileWithParser` | `parseFileWithParser(parserName: string, filePath: string, content: string)` | `Promise<ParseResult>` |
| `parseFiles` | `parseFiles(files: string[], onProgress: ProgressCallback)` | `Promise<ParseResult[]>` |
| `parseProject` | `parseProject(config: ParseProjectConfig, onProgress: ProgressCallback)` | `Promise<ProjectParseResult>` |
| `clearCache` | `clearCache()` | `void` |
| `getCacheStats` | `getCacheStats()` | `{ entries: number; size: number }` |
| `destroy` | `destroy()` | `Promise<void>` |

## Where it refuses work

- `ParserOrchestrator` stops the work with an early return when `this.initialized`.
- `ParserOrchestrator` stops the work with an early return when `registration.parser.canParse(filePath)`.
- `ParserOrchestrator` stops the work with an early return when `first.entities?.length`.
- `ParserOrchestrator` stops the work with an early return when `next.entities?.length`.
- `ParserOrchestrator` stops the work with an early return when `!parserName`.
- `ParserOrchestrator` stops the work with an early return when `cached`.

## When something fails

- `ParserOrchestrator` handles failure in 4 places: it turns it into a return value in 3, and discards it silently in 1. A failure discarded silently leaves no trace for whoever debugs this later.
