import { Language } from '../core/model/ArkFile'; import { ModuleScene, Scene } from '../Scene'; import { ArkFile } from '../core/model/ArkFile'; import { ArkModule } from '../core/model/ArkModule'; import { ModuleDepthLevel } from './common/ModuleDepth'; export interface FrontendParseFailure { filePath: string; reason: unknown; } export interface FrontendParseResult { arkFiles: ArkFile[]; failedFiles: FrontendParseFailure[]; } /** * Dispatches language front-ends and exposes a single build entry for {@link Scene} so the scene no longer * branches on {@link Language} to pick {@link import('../core/model/builder/ArkFileBuilder').buildArkFileFromFile} * vs the C++ builder. */ export declare class FrontendBuilder { private static partitionFilePaths; private static collectFailedFilePaths; static buildFilesIntoArkFiles(scene: Scene, filePaths: string[]): void; static buildModuleFilesIntoArkFiles(moduleScene: ModuleScene, filePaths: string[]): void; /** * Builds a single project file into a pre-allocated {@link ArkFile} (the former `if (CXX) … else …` in `Scene`). */ static buildProjectFileIntoArkFile(scene: Scene, filePath: string, arkFile: ArkFile): void; /** * Build all source files of an {@link ArkModule} up to the given {@link ModuleDepthLevel}. * * Scans the module directory for source files using scene options * (supportFileExts / ignoreFileNames), creates an {@link ArkFile} for each file, registers it * with the module and scene, and builds it to the requested level. Errors on individual files * are logged and do not abort the loop. * * @param scene - The owning {@link Scene}. * @param module - The module whose files are built. * @param level - The target depth level. */ static buildModuleFilesToLevel(scene: Scene, module: ArkModule, level: ModuleDepthLevel): void; /** * Scan the module directory and create path-only {@link ArkFile} shells (no content parsed), * registering each with the module and scene. * * Each shell has language, filePath, projectDir, and fileSignature set, but no ImportInfo / * ExportInfo / ArkClass / ArkMethod. Callers subsequently build content via * {@link buildImports} then {@link upgradeArkFileToLevel} (SIGNATURES / BODIES), or * {@link buildArkFileToLevel} for a one-shot path. * * @param scene - The owning {@link Scene}. * @param module - The module whose directory is scanned. * @returns Array of created (and registered) ArkFile shells. */ static createModuleFileShells(scene: Scene, module: ArkModule): ArkFile[]; /** * Dispatch level-aware building to the appropriate frontend. * * - SIGNATURES: full namespace/class/method signatures are built (parameters, return types) * without method bodies, reusing {@link buildProjectFileIntoArkFile}. The mounted * BodyBuilders are released here so the ArkFile holds signatures only (no ArkBody/CFG). * - BODIES: same as SIGNATURES but the mounted BodyBuilders are **retained** (not released) * so that {@link buildModuleMethodBody} can build method bodies in a subsequent phase. */ private static buildArkFileToLevel; /** * Lightweight import/export parsing only (used as a step inside {@link ModuleBuilder.buildModuleToLevel}). */ static buildImports(arkFile: ArkFile, language: Language): void; /** * Upgrade an existing ArkFile (whose ImportInfo/ExportInfo were already populated) to * SIGNATURES or BODIES by building class/method/namespace signatures on top. * * For ArkTS files, this calls {@link ArktsFrontend.buildProjectFileForSignatures} which builds * signatures with `skipImportExport = true`, preserving existing import/export data and * avoiding duplication of `export *` re-export entries (whose temp clause keys are * process-level auto-increment and cannot be overwritten by `Map.set`). * * For C++ files, {@link CppFrontend.buildProjectFile} is safe to re-call: C++ ImportInfo uses * stable clause keys (`#include "..."` / namespace names) that are overwritten by `Map.set`, * and C++ ExportInfo is not produced during the import-only phase, so no duplication occurs. * * After signature building, BodyBuilders are released when the target level is SIGNATURES * (no ArkBody/CFG retained). For BODIES, BodyBuilders are retained so that * {@link buildModuleMethodBody} can build method bodies in a subsequent phase. * * @param scene - The owning {@link Scene}. * @param arkFile - The ArkFile to upgrade (must already have ImportInfo/ExportInfo). * @param language - The language of the file. * @param targetLevel - The target depth level (SIGNATURES or BODIES). */ static upgradeArkFileToLevel(scene: Scene, arkFile: ArkFile, language: Language, targetLevel: ModuleDepthLevel): void; /** * Release the BodyBuilder (or CxxBodyBuilder) mounted on a method, freeing the AST/build * context. */ private static freeMethodBodyBuilder; /** * Release the BodyBuilders mounted during signature building so the ArkFile retains only * signatures (no ArkBody/CFG) and does not retain AST/build context in memory. Mirrors the * release pattern in {@link Scene.parseAndRegisterSdkFile}. */ private static freeBodyBuildersInFile; /** * Build method bodies (ArkBody/CFG/Stmt/Expr) for all ArkFiles in the given module, then * run default-constructor post-processing. This is the module-scoped equivalent of * {@link Scene.buildAllMethodBody} + {@link Scene.updateOrAddDefaultConstructors}, following * the same two-phase pattern as {@link Scene.genArkFiles}. * * Phase 1 (signatures + mounted BodyBuilders) is performed earlier by * {@link buildModuleFilesToLevel} at {@link ModuleDepthLevel.BODIES}, which retains the * mounted BodyBuilders. This method performs phase 2: * * 1. Set {@link Scene.buildStage} to {@link SceneBuildStage.CLASS_DONE} (opening the * {@link Scene.buildClassDone} gate) so that when BodyBuilder encounters nested/anonymous * methods during body construction, their {@link ArkMethod.setBodyBuilder} calls * immediately trigger {@link ArkMethod.buildBody} — recursively building nested method * bodies. The previous buildStage is restored afterwards so that subsequent SIGNATURES- * level module loading is unaffected. * 2. Collect all methods in the module's files. * 3. Call {@link ArkMethod.buildBody} on each (executes the retained BodyBuilder), then free * the BodyBuilder to release AST/build context. * 4. Run {@link buildDefaultConstructor} / {@link replaceSuper2Constructor} / * {@link addInitInConstructor} on the module's files (gate still open). * * Calls {@link ModelUtils.dispose} after each module's method bodies are built to release * global caches (implicitArkUIBuilderMethods, popMethodSignatureCache) that accumulate during * body building. * * @param module - The module whose files' method bodies are to be built. */ static buildModuleMethodBody(module: ArkModule): void; /** * Run {@link buildDefaultConstructor} / {@link replaceSuper2Constructor} / * {@link addInitInConstructor} on all classes in a file. These create/modify constructors; * {@link buildDefaultConstructor} builds bodies directly (without BodyBuilder), and the * other two only modify already-built bodies. */ private static processDefaultConstructors; } //# sourceMappingURL=FrontendBuilder.d.ts.map