From 623f43b6bea391af859ea422eef9aeef2202845b Mon Sep 17 00:00:00 2001 From: l00913061 Date: Thu, 28 Aug 2025 11:10:47 +0800 Subject: [PATCH] fileManager Signed-off-by: l00913061 --- .../bindings/src/common/ui_plugins_driver.ts | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/ets2panda/bindings/src/common/ui_plugins_driver.ts b/ets2panda/bindings/src/common/ui_plugins_driver.ts index 464cd6b396..9c55f5be57 100644 --- a/ets2panda/bindings/src/common/ui_plugins_driver.ts +++ b/ets2panda/bindings/src/common/ui_plugins_driver.ts @@ -14,6 +14,7 @@ */ import { KNativePointer } from './InteropTypes'; +import { LANGUAGE_VERSION } from './preDefine'; import { BuildConfig } from './types'; export enum PluginHook { @@ -60,12 +61,57 @@ type RawPlugins = { init: PluginInitFunction | undefined; }; +export interface DependentModuleConfig { + packageName: string; + moduleName: string; + moduleType: string; + modulePath: string; + sourceRoots: string[]; + entryFile: string; + language: string; + declFilesPath?: string; + dependencies?: string[]; + abcPath?: string; + declgenV1OutPath?: string; + declgenV2OutPath?: string; + declgenBridgeCodePath?: string; + byteCodeHar: boolean; +} + +export class FileManager { + private static instance: FileManager | undefined = undefined; + static arkTSModuleMap: Map = new Map(); + static staticApiPath: Set = new Set(); + static dynamicApiPath: Set = new Set(); + static buildConfig: BuildConfig; + private constructor() { } + + static setInstance(instance: FileManager | undefined): void { + if (instance === undefined) { + FileManager.instance = new FileManager(); + } + FileManager.instance = instance; + } + + static getInstance(): FileManager { + if (!FileManager.instance) { + throw Error('fileManager not exist.'); + } + return FileManager.instance; + } + + getLanguageVersionByFilePath(filePath: string): string { + return LANGUAGE_VERSION.ARKTS_1_2; + } +} + class PluginContext { private ast: object | undefined; private program: object | undefined; private projectConfig: object | undefined; private contextPtr: KNativePointer | undefined; private codingFilePath: string | undefined; + private fileManager: FileManager | undefined; constructor() { this.ast = undefined; @@ -75,6 +121,10 @@ class PluginContext { this.codingFilePath = undefined; } + public getFileManager(): FileManager | undefined { + return this.fileManager; + } + public setArkTSAst(ast: object): void { this.ast = ast; } -- Gitee