# MegaFileIndexer

**Kind:** Class

**Source:** [`atloria-monorepo/packages/doc-automation/src/v2/stages/stage-01-parse/mega-file-indexer.ts`](https://github.com/sherkety/atloria/blob/main/atloria-monorepo/packages/doc-automation/src/v2/stages/stage-01-parse/mega-file-indexer.ts#L47)

Mega File Indexer - Handles extremely large files with phased extraction

## Methods

| Method | Signature | Returns |
|---|---|---|
| `detectMegaFile` | `detectMegaFile(filePath: string)` | `Promise<MegaFileDetectionResult>` |
| `createIndex` | `createIndex(filePath: string)` | `Promise<MegaFileIndex>` |
| `extractAllPhases` | `extractAllPhases(filePath: string)` | `Promise<MegaFilePhaseExtractionResult>` |
| `loadSection` | `loadSection(filePath: string, startLine: number, endLine: number)` | `Promise<string>` |
| `loadEntity` | `loadEntity(index: MegaFileIndex, entityName: string)` | `Promise<string | null>` |

## Where it refuses work

- `MegaFileIndexer` stops the work with an early return when `seen.has(key)`.
- `MegaFileIndexer` stops the work with an early return when `callPattern.test(content)`.
- `MegaFileIndexer` stops the work with an early return when `extendsPattern.test(content)`.
- `MegaFileIndexer` stops the work with an early return when `!entity`.

## When something fails

- `MegaFileIndexer` handles failure in 2 places: it logs it and continues in 1, and turns it into a return value in 1.
