From 32450cf67a0e83b000c527b4be8305e5442c07de Mon Sep 17 00:00:00 2001 From: maoruihao Date: Tue, 22 Jul 2025 21:15:24 +0800 Subject: [PATCH] =?UTF-8?q?ets-checker=E8=93=9D=E9=BB=84=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: maoruihao --- compiler/src/ets_checker.ts | 35 ++++++++++--------- .../ets_ui/rollup-plugin-ets-checker.ts | 10 +++--- 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/compiler/src/ets_checker.ts b/compiler/src/ets_checker.ts index a776891af..b1954455d 100644 --- a/compiler/src/ets_checker.ts +++ b/compiler/src/ets_checker.ts @@ -46,7 +46,6 @@ import { ESMODULE, EXTNAME_D_ETS, EXTNAME_JS, - EXTNAME_ETS, FOREACH_LAZYFOREACH, COMPONENT_IF, TS_WATCH_END_MSG, @@ -110,7 +109,8 @@ import { } from './fast_build/ark_compiler/interop/process_arkts_evolution'; import { generateDeclarationFileForSTS, - isMixCompile, isRemoteModule + isMixCompile, + isRemoteModule } from './fast_build/ark_compiler/interop/interop_manager'; export interface LanguageServiceCache { @@ -148,6 +148,7 @@ const buildInfoWriteFile: ts.WriteFileCallback = (fileName: string, data: string fs.closeSync(fd); } }; + // The collection records the file name and the corresponding version, where the version is the hash value of the text in last compilation. const filesBuildInfo: Map = new Map(); @@ -357,7 +358,7 @@ let setHashValueByFilePath: Function | undefined = undefined; let getHashByFilePath: Function | undefined = undefined; export function createLanguageService(rootFileNames: string[], resolveModulePaths: string[], - parentEvent?: CompileEvent, rollupShareObject?: any): ts.LanguageService { + parentEvent?: CompileEvent, rollupShareObject?: Object): ts.LanguageService { setHashValueByFilePath = rollupShareObject?.setHashValueByFilePath; getHashByFilePath = rollupShareObject?.getHashByFilePath; setCompilerOptions(resolveModulePaths); @@ -370,12 +371,12 @@ export function createLanguageService(rootFileNames: string[], resolveModulePath } let fileContent: string = getFileContentWithHash(fileName); if (/(? = new Map(); export function resolveModuleNames(moduleNames: string[], containingFile: string): ts.ResolvedModuleFull[] { - ts.PerformanceDotting.startAdvanced('resolveModuleNames'); + ts.PerformanceDotting?.startAdvanced('resolveModuleNames'); const resolvedModules: ts.ResolvedModuleFull[] = []; const cacheFileContent: ts.ResolvedModuleFull[] = resolvedModulesCache.get(path.resolve(containingFile)); if (![...shouldResolvedFiles].length || shouldResolvedFiles.has(path.resolve(containingFile)) || @@ -1216,7 +1217,7 @@ export function resolveModuleNames(moduleNames: string[], containingFile: string const DETSModulePath: string = path.resolve(path.dirname(containingFile), /\.d\.ets$/.test(moduleName) ? moduleName : moduleName + EXTNAME_D_ETS); const arktsEvoDeclFilePath: string = isMixCompile() ? - getArkTSEvoDeclFilePath({ moduleRequest: moduleName, resolvedFileName: '' }) : ''; + getArkTSEvoDeclFilePath({ moduleRequest: moduleName, resolvedFileName: '' }) : ''; if (ts.sys.fileExists(modulePath)) { resolvedModules.push(getResolveModule(modulePath, '.d.ts')); } else if (ts.sys.fileExists(systemDETSModulePath)) { @@ -1264,10 +1265,10 @@ export function resolveModuleNames(moduleNames: string[], containingFile: string createOrUpdateCache(resolvedModules, path.resolve(containingFile)); } resolvedModulesCache.set(path.resolve(containingFile), resolvedModules); - ts.PerformanceDotting.stopAdvanced('resolveModuleNames'); + ts.PerformanceDotting?.stopAdvanced('resolveModuleNames'); return resolvedModules; } - ts.PerformanceDotting.stopAdvanced('resolveModuleNames'); + ts.PerformanceDotting?.stopAdvanced('resolveModuleNames'); return resolvedModulesCache.get(path.resolve(containingFile)); } @@ -1693,14 +1694,14 @@ export function runArkTSLinter(errorCodeLogger?: Object | undefined, parentEvent buildInfoWriteFile, errorCodeLogger); - ts.PerformanceDotting.startAdvanced('updateErrorFile'); + ts.PerformanceDotting?.startAdvanced('updateErrorFile'); if (process.env.watchMode !== 'true' && !projectConfig.xtsMode) { arkTSLinterDiagnostics.forEach((diagnostic: ts.Diagnostic) => { updateErrorFileCache(diagnostic); }); timePrinterInstance.appendTime(ts.TimePhase.UPDATE_ERROR_FILE); } - ts.PerformanceDotting.stopAdvanced('updateErrorFile'); + ts.PerformanceDotting?.stopAdvanced('updateErrorFile'); timePrinterInstance.printTimes(); ts.ArkTSLinterTimePrinter.destroyInstance(); } diff --git a/compiler/src/fast_build/ets_ui/rollup-plugin-ets-checker.ts b/compiler/src/fast_build/ets_ui/rollup-plugin-ets-checker.ts index e3f33e78d..031fce3a5 100644 --- a/compiler/src/fast_build/ets_ui/rollup-plugin-ets-checker.ts +++ b/compiler/src/fast_build/ets_ui/rollup-plugin-ets-checker.ts @@ -31,13 +31,11 @@ import { targetESVersionChanged, collectFileToIgnoreDiagnostics, TSC_SYSTEM_CODE, - traverseProgramSourceFiles, - arkTsEvolutionModuleMap, - cleanUpArkTsEvolutionModuleMap, + traverseProgramSourceFiles } from '../../ets_checker'; import { TS_WATCH_END_MSG } from '../../pre_define'; import { - setChecker, + setChecker } from '../../utils'; import { configureSyscapInfo, @@ -117,7 +115,7 @@ export function etsChecker() { } if (process.env.watchMode === 'true') { !executedOnce && serviceChecker(rootFileNames, logger, resolveModulePaths, eventServiceChecker, this.share); - ts.PerformanceDotting.startAdvanced('diagnostic'); + ts.PerformanceDotting?.startAdvanced('diagnostic'); if (executedOnce) { const timePrinterInstance = ts.ArkTSLinterTimePrinter.getInstance(); timePrinterInstance.setArkTSTimePrintSwitch(false); @@ -137,7 +135,7 @@ export function etsChecker() { const allDiagnostics: ts.Diagnostic[] = globalProgram.builderProgram .getSyntacticDiagnostics() .concat(globalProgram.builderProgram.getSemanticDiagnostics()); - ts.PerformanceDotting.stopAdvanced('diagnostic'); + ts.PerformanceDotting?.stopAdvanced('diagnostic'); emitBuildInfo(); let errorCodeLogger: Object | undefined = this.share?.getHvigorConsoleLogger ? this.share?.getHvigorConsoleLogger(TSC_SYSTEM_CODE) : undefined; -- Gitee