diff --git a/lib/tsc.js b/lib/tsc.js index 85a72f8be8593f730da171e5510c7a6477e4fee0..f3aa4ff32b2a950597de241a03ed3624f73671d1 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -39074,11 +39074,12 @@ function getKitJsonObject(name, sdkPath, compilerOptions) { if (kitJsonCache == null ? void 0 : kitJsonCache.has(name)) { return kitJsonCache.get(name); } - const OHOS_KIT_CONFIG_PATH = isMixedCompilerSDKPath(compilerOptions) ? "./openharmony/ets/ets1.1/build-tools/ets-loader/kit_configs" : "./openharmony/ets/build-tools/ets-loader/kit_configs"; - const HMS_KIT_CONFIG_PATH = isMixedCompilerSDKPath(compilerOptions) ? "./hms/ets/ets1.1/build-tools/ets-loader/kit_configs" : "./hms/ets/build-tools/ets-loader/kit_configs"; + const OHOS_KIT_CONFIG_PATH = ohosKitConfigPath(compilerOptions); + const HMS_KIT_CONFIG_PATH = hmsKitConfigPath(compilerOptions); const ohosJsonPath = resolvePath(sdkPath, OHOS_KIT_CONFIG_PATH, `./${name}${JSON_SUFFIX}`); const hmsJsonPath = resolvePath(sdkPath, HMS_KIT_CONFIG_PATH, `./${name}${JSON_SUFFIX}`); - let fileInfo = sys.fileExists(ohosJsonPath) ? sys.readFile(ohosJsonPath, "utf-8") : sys.fileExists(hmsJsonPath) ? sys.readFile(hmsJsonPath, "utf-8") : void 0; + const ohJsonPath = ohKitConfigJsonPath(compilerOptions, ohosJsonPath); + let fileInfo = sys.fileExists(ohosJsonPath) ? sys.readFile(ohosJsonPath, "utf-8") : sys.fileExists(hmsJsonPath) ? sys.readFile(hmsJsonPath, "utf-8") : sys.fileExists(ohJsonPath) ? sys.readFile(ohJsonPath, "utf-8") : void 0; if (!fileInfo) { kitJsonCache == null ? void 0 : kitJsonCache.set(name, void 0); return void 0; @@ -39091,10 +39092,26 @@ function isMixedCompilerSDKPath(compilerOptions) { if (!compilerOptions.etsLoaderPath) { return false; } - if (normalizePath(compilerOptions.etsLoaderPath).endsWith("ets1.1/build-tools/ets-loader")) { - return true; + return normalizePath(compilerOptions.etsLoaderPath).endsWith("ets1.1/build-tools/ets-loader"); +} +function isOhSDKPath(compilerOptions) { + if (!compilerOptions.etsLoaderPath) { + return false; } - return false; + return normalizePath(compilerOptions.etsLoaderPath).includes("OpenHarmony/SDK"); +} +function ohosKitConfigPath(compilerOptions) { + if (!isOhSDKPath(compilerOptions) && isMixedCompilerSDKPath(compilerOptions)) { + return "./openharmony/ets/ets1.1/build-tools/ets-loader/kit_configs"; + } else { + return "./openharmony/ets/build-tools/ets-loader/kit_configs"; + } +} +function hmsKitConfigPath(compilerOptions) { + return isMixedCompilerSDKPath(compilerOptions) ? "./hms/ets/ets1.1/build-tools/ets-loader/kit_configs" : "./hms/ets/build-tools/ets-loader/kit_configs"; +} +function ohKitConfigJsonPath(compilerOptions, ohosJsonPath) { + return isOhSDKPath(compilerOptions) ? `${compilerOptions.etsLoaderPath}/kit_configs` : ohosJsonPath; } function cleanKitJsonCache() { kitJsonCache == null ? void 0 : kitJsonCache.clear(); diff --git a/lib/tsserver.js b/lib/tsserver.js index 29f28e5ba8541fc03671ea9a57c9ee9b0a581b29..e9e816338048ee69c6678811253b8e6ec426cacd 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -1815,6 +1815,7 @@ __export(server_exports, { isObjectLiteralOrClassExpressionMethodOrAccessor: () => isObjectLiteralOrClassExpressionMethodOrAccessor, isObjectTypeDeclaration: () => isObjectTypeDeclaration, isOctalDigit: () => isOctalDigit, + isOhSDKPath: () => isOhSDKPath, isOhpm: () => isOhpm, isOhpmAndOhModules: () => isOhpmAndOhModules, isOmittedExpression: () => isOmittedExpression, @@ -41763,11 +41764,12 @@ function getKitJsonObject(name, sdkPath, compilerOptions) { if (kitJsonCache == null ? void 0 : kitJsonCache.has(name)) { return kitJsonCache.get(name); } - const OHOS_KIT_CONFIG_PATH = isMixedCompilerSDKPath(compilerOptions) ? "./openharmony/ets/ets1.1/build-tools/ets-loader/kit_configs" : "./openharmony/ets/build-tools/ets-loader/kit_configs"; - const HMS_KIT_CONFIG_PATH = isMixedCompilerSDKPath(compilerOptions) ? "./hms/ets/ets1.1/build-tools/ets-loader/kit_configs" : "./hms/ets/build-tools/ets-loader/kit_configs"; + const OHOS_KIT_CONFIG_PATH = ohosKitConfigPath(compilerOptions); + const HMS_KIT_CONFIG_PATH = hmsKitConfigPath(compilerOptions); const ohosJsonPath = resolvePath(sdkPath, OHOS_KIT_CONFIG_PATH, `./${name}${JSON_SUFFIX}`); const hmsJsonPath = resolvePath(sdkPath, HMS_KIT_CONFIG_PATH, `./${name}${JSON_SUFFIX}`); - let fileInfo = sys.fileExists(ohosJsonPath) ? sys.readFile(ohosJsonPath, "utf-8") : sys.fileExists(hmsJsonPath) ? sys.readFile(hmsJsonPath, "utf-8") : void 0; + const ohJsonPath = ohKitConfigJsonPath(compilerOptions, ohosJsonPath); + let fileInfo = sys.fileExists(ohosJsonPath) ? sys.readFile(ohosJsonPath, "utf-8") : sys.fileExists(hmsJsonPath) ? sys.readFile(hmsJsonPath, "utf-8") : sys.fileExists(ohJsonPath) ? sys.readFile(ohJsonPath, "utf-8") : void 0; if (!fileInfo) { kitJsonCache == null ? void 0 : kitJsonCache.set(name, void 0); return void 0; @@ -41780,10 +41782,26 @@ function isMixedCompilerSDKPath(compilerOptions) { if (!compilerOptions.etsLoaderPath) { return false; } - if (normalizePath(compilerOptions.etsLoaderPath).endsWith("ets1.1/build-tools/ets-loader")) { - return true; + return normalizePath(compilerOptions.etsLoaderPath).endsWith("ets1.1/build-tools/ets-loader"); +} +function isOhSDKPath(compilerOptions) { + if (!compilerOptions.etsLoaderPath) { + return false; } - return false; + return normalizePath(compilerOptions.etsLoaderPath).includes("OpenHarmony/SDK"); +} +function ohosKitConfigPath(compilerOptions) { + if (!isOhSDKPath(compilerOptions) && isMixedCompilerSDKPath(compilerOptions)) { + return "./openharmony/ets/ets1.1/build-tools/ets-loader/kit_configs"; + } else { + return "./openharmony/ets/build-tools/ets-loader/kit_configs"; + } +} +function hmsKitConfigPath(compilerOptions) { + return isMixedCompilerSDKPath(compilerOptions) ? "./hms/ets/ets1.1/build-tools/ets-loader/kit_configs" : "./hms/ets/build-tools/ets-loader/kit_configs"; +} +function ohKitConfigJsonPath(compilerOptions, ohosJsonPath) { + return isOhSDKPath(compilerOptions) ? `${compilerOptions.etsLoaderPath}/kit_configs` : ohosJsonPath; } function cleanKitJsonCache() { kitJsonCache == null ? void 0 : kitJsonCache.clear(); @@ -118118,6 +118136,7 @@ __export(ts_exports3, { isObjectLiteralOrClassExpressionMethodOrAccessor: () => isObjectLiteralOrClassExpressionMethodOrAccessor, isObjectTypeDeclaration: () => isObjectTypeDeclaration, isOctalDigit: () => isOctalDigit, + isOhSDKPath: () => isOhSDKPath, isOhpm: () => isOhpm, isOhpmAndOhModules: () => isOhpmAndOhModules, isOmittedExpression: () => isOmittedExpression, @@ -178910,6 +178929,7 @@ if (typeof process !== "undefined") { isObjectLiteralOrClassExpressionMethodOrAccessor, isObjectTypeDeclaration, isOctalDigit, + isOhSDKPath, isOhpm, isOhpmAndOhModules, isOmittedExpression, diff --git a/lib/tsserverlibrary.d.ts b/lib/tsserverlibrary.d.ts index b30d6a1d65f53cfbd20897abb0281d2224702c9b..6d2f3e78b312859d71817234da8533696cf334f4 100644 --- a/lib/tsserverlibrary.d.ts +++ b/lib/tsserverlibrary.d.ts @@ -9856,6 +9856,7 @@ declare namespace ts { function hasTsNoCheckOrTsIgnoreFlag(node: SourceFile): boolean; function createObfTextSingleLineWriter(): EmitTextWriter; function isMixedCompilerSDKPath(compilerOptions: CompilerOptions): boolean; + function isOhSDKPath(compilerOptions: CompilerOptions): boolean; function cleanKitJsonCache(): void; function getMaxFlowDepth(compilerOptions: CompilerOptions): number; function getErrorCode(diagnostic: Diagnostic): ErrorInfo; diff --git a/lib/tsserverlibrary.js b/lib/tsserverlibrary.js index 730522f823e7b5e5040626dc6ec9a82d8bef493d..b8cc62af21adca5f3d656538db8bfd95336d12a5 100644 --- a/lib/tsserverlibrary.js +++ b/lib/tsserverlibrary.js @@ -1815,6 +1815,7 @@ __export(tsserverlibrary_exports, { isObjectLiteralOrClassExpressionMethodOrAccessor: () => isObjectLiteralOrClassExpressionMethodOrAccessor, isObjectTypeDeclaration: () => isObjectTypeDeclaration, isOctalDigit: () => isOctalDigit, + isOhSDKPath: () => isOhSDKPath, isOhpm: () => isOhpm, isOhpmAndOhModules: () => isOhpmAndOhModules, isOmittedExpression: () => isOmittedExpression, @@ -41665,11 +41666,12 @@ function getKitJsonObject(name, sdkPath, compilerOptions) { if (kitJsonCache == null ? void 0 : kitJsonCache.has(name)) { return kitJsonCache.get(name); } - const OHOS_KIT_CONFIG_PATH = isMixedCompilerSDKPath(compilerOptions) ? "./openharmony/ets/ets1.1/build-tools/ets-loader/kit_configs" : "./openharmony/ets/build-tools/ets-loader/kit_configs"; - const HMS_KIT_CONFIG_PATH = isMixedCompilerSDKPath(compilerOptions) ? "./hms/ets/ets1.1/build-tools/ets-loader/kit_configs" : "./hms/ets/build-tools/ets-loader/kit_configs"; + const OHOS_KIT_CONFIG_PATH = ohosKitConfigPath(compilerOptions); + const HMS_KIT_CONFIG_PATH = hmsKitConfigPath(compilerOptions); const ohosJsonPath = resolvePath(sdkPath, OHOS_KIT_CONFIG_PATH, `./${name}${JSON_SUFFIX}`); const hmsJsonPath = resolvePath(sdkPath, HMS_KIT_CONFIG_PATH, `./${name}${JSON_SUFFIX}`); - let fileInfo = sys.fileExists(ohosJsonPath) ? sys.readFile(ohosJsonPath, "utf-8") : sys.fileExists(hmsJsonPath) ? sys.readFile(hmsJsonPath, "utf-8") : void 0; + const ohJsonPath = ohKitConfigJsonPath(compilerOptions, ohosJsonPath); + let fileInfo = sys.fileExists(ohosJsonPath) ? sys.readFile(ohosJsonPath, "utf-8") : sys.fileExists(hmsJsonPath) ? sys.readFile(hmsJsonPath, "utf-8") : sys.fileExists(ohJsonPath) ? sys.readFile(ohJsonPath, "utf-8") : void 0; if (!fileInfo) { kitJsonCache == null ? void 0 : kitJsonCache.set(name, void 0); return void 0; @@ -41682,10 +41684,26 @@ function isMixedCompilerSDKPath(compilerOptions) { if (!compilerOptions.etsLoaderPath) { return false; } - if (normalizePath(compilerOptions.etsLoaderPath).endsWith("ets1.1/build-tools/ets-loader")) { - return true; + return normalizePath(compilerOptions.etsLoaderPath).endsWith("ets1.1/build-tools/ets-loader"); +} +function isOhSDKPath(compilerOptions) { + if (!compilerOptions.etsLoaderPath) { + return false; } - return false; + return normalizePath(compilerOptions.etsLoaderPath).includes("OpenHarmony/SDK"); +} +function ohosKitConfigPath(compilerOptions) { + if (!isOhSDKPath(compilerOptions) && isMixedCompilerSDKPath(compilerOptions)) { + return "./openharmony/ets/ets1.1/build-tools/ets-loader/kit_configs"; + } else { + return "./openharmony/ets/build-tools/ets-loader/kit_configs"; + } +} +function hmsKitConfigPath(compilerOptions) { + return isMixedCompilerSDKPath(compilerOptions) ? "./hms/ets/ets1.1/build-tools/ets-loader/kit_configs" : "./hms/ets/build-tools/ets-loader/kit_configs"; +} +function ohKitConfigJsonPath(compilerOptions, ohosJsonPath) { + return isOhSDKPath(compilerOptions) ? `${compilerOptions.etsLoaderPath}/kit_configs` : ohosJsonPath; } function cleanKitJsonCache() { kitJsonCache == null ? void 0 : kitJsonCache.clear(); @@ -154584,6 +154602,7 @@ __export(ts_exports3, { isObjectLiteralOrClassExpressionMethodOrAccessor: () => isObjectLiteralOrClassExpressionMethodOrAccessor, isObjectTypeDeclaration: () => isObjectTypeDeclaration, isOctalDigit: () => isOctalDigit, + isOhSDKPath: () => isOhSDKPath, isOhpm: () => isOhpm, isOhpmAndOhModules: () => isOhpmAndOhModules, isOmittedExpression: () => isOmittedExpression, @@ -177907,6 +177926,7 @@ __export(ts_server_exports3, { isObjectLiteralOrClassExpressionMethodOrAccessor, isObjectTypeDeclaration, isOctalDigit, + isOhSDKPath, isOhpm, isOhpmAndOhModules, isOmittedExpression, diff --git a/lib/typescript.d.ts b/lib/typescript.d.ts index 2b76bcd165c62aa372ef799e4e8b12ae0c8f6b3b..2bfe957dd041b1133719776d8b3e1ca093255bf1 100644 --- a/lib/typescript.d.ts +++ b/lib/typescript.d.ts @@ -5853,6 +5853,7 @@ declare namespace ts { function hasTsNoCheckOrTsIgnoreFlag(node: SourceFile): boolean; function createObfTextSingleLineWriter(): EmitTextWriter; function isMixedCompilerSDKPath(compilerOptions: CompilerOptions): boolean; + function isOhSDKPath(compilerOptions: CompilerOptions): boolean; function cleanKitJsonCache(): void; function getMaxFlowDepth(compilerOptions: CompilerOptions): number; function getErrorCode(diagnostic: Diagnostic): ErrorInfo; diff --git a/lib/typescript.js b/lib/typescript.js index 0d0d5531a45f0b1c6c7844c7361b00d08fc18aa9..3ff14cd447a77715541e32fc496e0f878313eee7 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -1815,6 +1815,7 @@ __export(typescript_exports, { isObjectLiteralOrClassExpressionMethodOrAccessor: () => isObjectLiteralOrClassExpressionMethodOrAccessor, isObjectTypeDeclaration: () => isObjectTypeDeclaration, isOctalDigit: () => isOctalDigit, + isOhSDKPath: () => isOhSDKPath, isOhpm: () => isOhpm, isOhpmAndOhModules: () => isOhpmAndOhModules, isOmittedExpression: () => isOmittedExpression, @@ -41680,11 +41681,12 @@ function getKitJsonObject(name, sdkPath, compilerOptions) { if (kitJsonCache == null ? void 0 : kitJsonCache.has(name)) { return kitJsonCache.get(name); } - const OHOS_KIT_CONFIG_PATH = isMixedCompilerSDKPath(compilerOptions) ? "./openharmony/ets/ets1.1/build-tools/ets-loader/kit_configs" : "./openharmony/ets/build-tools/ets-loader/kit_configs"; - const HMS_KIT_CONFIG_PATH = isMixedCompilerSDKPath(compilerOptions) ? "./hms/ets/ets1.1/build-tools/ets-loader/kit_configs" : "./hms/ets/build-tools/ets-loader/kit_configs"; + const OHOS_KIT_CONFIG_PATH = ohosKitConfigPath(compilerOptions); + const HMS_KIT_CONFIG_PATH = hmsKitConfigPath(compilerOptions); const ohosJsonPath = resolvePath(sdkPath, OHOS_KIT_CONFIG_PATH, `./${name}${JSON_SUFFIX}`); const hmsJsonPath = resolvePath(sdkPath, HMS_KIT_CONFIG_PATH, `./${name}${JSON_SUFFIX}`); - let fileInfo = sys.fileExists(ohosJsonPath) ? sys.readFile(ohosJsonPath, "utf-8") : sys.fileExists(hmsJsonPath) ? sys.readFile(hmsJsonPath, "utf-8") : void 0; + const ohJsonPath = ohKitConfigJsonPath(compilerOptions, ohosJsonPath); + let fileInfo = sys.fileExists(ohosJsonPath) ? sys.readFile(ohosJsonPath, "utf-8") : sys.fileExists(hmsJsonPath) ? sys.readFile(hmsJsonPath, "utf-8") : sys.fileExists(ohJsonPath) ? sys.readFile(ohJsonPath, "utf-8") : void 0; if (!fileInfo) { kitJsonCache == null ? void 0 : kitJsonCache.set(name, void 0); return void 0; @@ -41697,10 +41699,26 @@ function isMixedCompilerSDKPath(compilerOptions) { if (!compilerOptions.etsLoaderPath) { return false; } - if (normalizePath(compilerOptions.etsLoaderPath).endsWith("ets1.1/build-tools/ets-loader")) { - return true; + return normalizePath(compilerOptions.etsLoaderPath).endsWith("ets1.1/build-tools/ets-loader"); +} +function isOhSDKPath(compilerOptions) { + if (!compilerOptions.etsLoaderPath) { + return false; } - return false; + return normalizePath(compilerOptions.etsLoaderPath).includes("OpenHarmony/SDK"); +} +function ohosKitConfigPath(compilerOptions) { + if (!isOhSDKPath(compilerOptions) && isMixedCompilerSDKPath(compilerOptions)) { + return "./openharmony/ets/ets1.1/build-tools/ets-loader/kit_configs"; + } else { + return "./openharmony/ets/build-tools/ets-loader/kit_configs"; + } +} +function hmsKitConfigPath(compilerOptions) { + return isMixedCompilerSDKPath(compilerOptions) ? "./hms/ets/ets1.1/build-tools/ets-loader/kit_configs" : "./hms/ets/build-tools/ets-loader/kit_configs"; +} +function ohKitConfigJsonPath(compilerOptions, ohosJsonPath) { + return isOhSDKPath(compilerOptions) ? `${compilerOptions.etsLoaderPath}/kit_configs` : ohosJsonPath; } function cleanKitJsonCache() { kitJsonCache == null ? void 0 : kitJsonCache.clear(); @@ -166134,6 +166152,7 @@ if (typeof console !== "undefined") { isObjectLiteralOrClassExpressionMethodOrAccessor, isObjectTypeDeclaration, isOctalDigit, + isOhSDKPath, isOhpm, isOhpmAndOhModules, isOmittedExpression, diff --git a/lib/typingsInstaller.js b/lib/typingsInstaller.js index 32a1b753f99c1cfa8b47768b07550d5c8feddfe0..66e5e9a776779604daf78fcef66a1d94c7fad317 100644 --- a/lib/typingsInstaller.js +++ b/lib/typingsInstaller.js @@ -29418,11 +29418,12 @@ function getKitJsonObject(name, sdkPath, compilerOptions) { if (kitJsonCache == null ? void 0 : kitJsonCache.has(name)) { return kitJsonCache.get(name); } - const OHOS_KIT_CONFIG_PATH = isMixedCompilerSDKPath(compilerOptions) ? "./openharmony/ets/ets1.1/build-tools/ets-loader/kit_configs" : "./openharmony/ets/build-tools/ets-loader/kit_configs"; - const HMS_KIT_CONFIG_PATH = isMixedCompilerSDKPath(compilerOptions) ? "./hms/ets/ets1.1/build-tools/ets-loader/kit_configs" : "./hms/ets/build-tools/ets-loader/kit_configs"; + const OHOS_KIT_CONFIG_PATH = ohosKitConfigPath(compilerOptions); + const HMS_KIT_CONFIG_PATH = hmsKitConfigPath(compilerOptions); const ohosJsonPath = resolvePath(sdkPath, OHOS_KIT_CONFIG_PATH, `./${name}${JSON_SUFFIX}`); const hmsJsonPath = resolvePath(sdkPath, HMS_KIT_CONFIG_PATH, `./${name}${JSON_SUFFIX}`); - let fileInfo = sys.fileExists(ohosJsonPath) ? sys.readFile(ohosJsonPath, "utf-8") : sys.fileExists(hmsJsonPath) ? sys.readFile(hmsJsonPath, "utf-8") : void 0; + const ohJsonPath = ohKitConfigJsonPath(compilerOptions, ohosJsonPath); + let fileInfo = sys.fileExists(ohosJsonPath) ? sys.readFile(ohosJsonPath, "utf-8") : sys.fileExists(hmsJsonPath) ? sys.readFile(hmsJsonPath, "utf-8") : sys.fileExists(ohJsonPath) ? sys.readFile(ohJsonPath, "utf-8") : void 0; if (!fileInfo) { kitJsonCache == null ? void 0 : kitJsonCache.set(name, void 0); return void 0; @@ -29435,10 +29436,26 @@ function isMixedCompilerSDKPath(compilerOptions) { if (!compilerOptions.etsLoaderPath) { return false; } - if (normalizePath(compilerOptions.etsLoaderPath).endsWith("ets1.1/build-tools/ets-loader")) { - return true; + return normalizePath(compilerOptions.etsLoaderPath).endsWith("ets1.1/build-tools/ets-loader"); +} +function isOhSDKPath(compilerOptions) { + if (!compilerOptions.etsLoaderPath) { + return false; } - return false; + return normalizePath(compilerOptions.etsLoaderPath).includes("OpenHarmony/SDK"); +} +function ohosKitConfigPath(compilerOptions) { + if (!isOhSDKPath(compilerOptions) && isMixedCompilerSDKPath(compilerOptions)) { + return "./openharmony/ets/ets1.1/build-tools/ets-loader/kit_configs"; + } else { + return "./openharmony/ets/build-tools/ets-loader/kit_configs"; + } +} +function hmsKitConfigPath(compilerOptions) { + return isMixedCompilerSDKPath(compilerOptions) ? "./hms/ets/ets1.1/build-tools/ets-loader/kit_configs" : "./hms/ets/build-tools/ets-loader/kit_configs"; +} +function ohKitConfigJsonPath(compilerOptions, ohosJsonPath) { + return isOhSDKPath(compilerOptions) ? `${compilerOptions.etsLoaderPath}/kit_configs` : ohosJsonPath; } function setVirtualNodeAndKitImportFlags(node, start = 0, end = 0) { node.virtual = true; diff --git a/src/compiler/ohApi.ts b/src/compiler/ohApi.ts index 7f0c87b11c5d8e1418b038b7c0b2001a3da50772..d3f42d1f6fc8bf4f28b113c8f4226c5069a7aa0f 100644 --- a/src/compiler/ohApi.ts +++ b/src/compiler/ohApi.ts @@ -1180,18 +1180,16 @@ function getKitJsonObject(name: string, sdkPath: string, compilerOptions: Compil if (kitJsonCache?.has(name)) { return kitJsonCache.get(name); } - const OHOS_KIT_CONFIG_PATH = isMixedCompilerSDKPath(compilerOptions) ? - './openharmony/ets/ets1.1/build-tools/ets-loader/kit_configs' : - './openharmony/ets/build-tools/ets-loader/kit_configs'; - const HMS_KIT_CONFIG_PATH = isMixedCompilerSDKPath(compilerOptions) ? - './hms/ets/ets1.1/build-tools/ets-loader/kit_configs' : - './hms/ets/build-tools/ets-loader/kit_configs'; + const OHOS_KIT_CONFIG_PATH = ohosKitConfigPath(compilerOptions); + const HMS_KIT_CONFIG_PATH = hmsKitConfigPath(compilerOptions); const ohosJsonPath = resolvePath(sdkPath, OHOS_KIT_CONFIG_PATH, `./${name}${JSON_SUFFIX}`); const hmsJsonPath = resolvePath(sdkPath, HMS_KIT_CONFIG_PATH, `./${name}${JSON_SUFFIX}`); + const ohJsonPath = ohKitConfigJsonPath(compilerOptions, ohosJsonPath); let fileInfo: string | undefined = sys.fileExists(ohosJsonPath) ? sys.readFile(ohosJsonPath, 'utf-8') : sys.fileExists(hmsJsonPath) ? sys.readFile(hmsJsonPath, 'utf-8') : + sys.fileExists(ohJsonPath) ? sys.readFile(ohJsonPath, 'utf-8') : undefined; if (!fileInfo) { kitJsonCache?.set(name, undefined); @@ -1209,10 +1207,32 @@ export function isMixedCompilerSDKPath(compilerOptions: CompilerOptions): boolea if (!compilerOptions.etsLoaderPath) { return false; } - if (normalizePath(compilerOptions.etsLoaderPath).endsWith('ets1.1/build-tools/ets-loader')) { - return true; + return normalizePath(compilerOptions.etsLoaderPath).endsWith('ets1.1/build-tools/ets-loader'); +} + +export function isOhSDKPath(compilerOptions: CompilerOptions): boolean { + if (!compilerOptions.etsLoaderPath) { + return false; } - return false; + return normalizePath(compilerOptions.etsLoaderPath).includes('OpenHarmony/SDK'); +} + +function ohosKitConfigPath(compilerOptions: CompilerOptions): string { + if (!isOhSDKPath(compilerOptions) && isMixedCompilerSDKPath(compilerOptions)) { + return './openharmony/ets/ets1.1/build-tools/ets-loader/kit_configs'; + } else { + return './openharmony/ets/build-tools/ets-loader/kit_configs'; + } +} + +function hmsKitConfigPath(compilerOptions: CompilerOptions): string { + return isMixedCompilerSDKPath(compilerOptions) ? + './hms/ets/ets1.1/build-tools/ets-loader/kit_configs' : + './hms/ets/build-tools/ets-loader/kit_configs'; +} + +function ohKitConfigJsonPath(compilerOptions: CompilerOptions, ohosJsonPath: string): string { + return isOhSDKPath(compilerOptions) ? `${compilerOptions.etsLoaderPath}/kit_configs` : ohosJsonPath; } export function cleanKitJsonCache(): void { diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index b30d6a1d65f53cfbd20897abb0281d2224702c9b..6d2f3e78b312859d71817234da8533696cf334f4 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -9856,6 +9856,7 @@ declare namespace ts { function hasTsNoCheckOrTsIgnoreFlag(node: SourceFile): boolean; function createObfTextSingleLineWriter(): EmitTextWriter; function isMixedCompilerSDKPath(compilerOptions: CompilerOptions): boolean; + function isOhSDKPath(compilerOptions: CompilerOptions): boolean; function cleanKitJsonCache(): void; function getMaxFlowDepth(compilerOptions: CompilerOptions): number; function getErrorCode(diagnostic: Diagnostic): ErrorInfo; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 2b76bcd165c62aa372ef799e4e8b12ae0c8f6b3b..2bfe957dd041b1133719776d8b3e1ca093255bf1 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -5853,6 +5853,7 @@ declare namespace ts { function hasTsNoCheckOrTsIgnoreFlag(node: SourceFile): boolean; function createObfTextSingleLineWriter(): EmitTextWriter; function isMixedCompilerSDKPath(compilerOptions: CompilerOptions): boolean; + function isOhSDKPath(compilerOptions: CompilerOptions): boolean; function cleanKitJsonCache(): void; function getMaxFlowDepth(compilerOptions: CompilerOptions): number; function getErrorCode(diagnostic: Diagnostic): ErrorInfo;