From e5e643c0ae03a62b870ab1cfbf3d2b90199645aa Mon Sep 17 00:00:00 2001 From: zju_wyx <22125041@zju.edu.cn> Date: Thu, 28 Aug 2025 10:14:25 +0800 Subject: [PATCH] skip .d.ets, .d.ts, js and oh_modules files when emit and printDeclarationDiagnostics Signed-off-by: zju_wyx <22125041@zju.edu.cn> Change-Id: Ic929a56172b842645205204b9729011cb3fef3e3 --- compiler/src/ets_checker.ts | 14 +++++++++++--- compiler/src/interop/src/ets_checker.ts | 14 +++++++++++--- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/compiler/src/ets_checker.ts b/compiler/src/ets_checker.ts index a56cd183d..71becdf93 100644 --- a/compiler/src/ets_checker.ts +++ b/compiler/src/ets_checker.ts @@ -772,7 +772,7 @@ function processBuildHap(cacheFile: string, rootFileNames: string[], parentEvent if ((/\.d\.e?ts$/).test(moduleFile)) { generateSourceFilesInHar(moduleFile, fs.readFileSync(moduleFile, 'utf-8'), path.extname(moduleFile), projectConfig, projectConfig.modulePathMap); - } else if ((/\.e?ts$/).test(moduleFile)) { + } else if ((/\.e?ts$/).test(moduleFile) && !toUnixPath(moduleFile).includes('/oh_modules/')) { emit = undefined; let sourcefile = globalProgram.program.getSourceFile(moduleFile); if (sourcefile) { @@ -790,8 +790,16 @@ function processBuildHap(cacheFile: string, rootFileNames: string[], parentEvent } function printDeclarationDiagnostics(errorCodeLogger?: Object | undefined): void { - globalProgram.builderProgram.getDeclarationDiagnostics().forEach((diagnostic: ts.Diagnostic) => { - printDiagnostic(diagnostic, ErrorCodeModule.TSC, errorCodeLogger); + globalProgram.program.getSourceFiles().forEach((sourceFile: ts.SourceFile) => { + if ((/\.d\.e?ts$/).test(sourceFile.fileName) || (/\.js$/).test(sourceFile.fileName)) { + return; + } + if (toUnixPath(sourceFile.fileName).includes('/oh_modules/')) { + return; + } + globalProgram.builderProgram.getDeclarationDiagnostics(sourceFile).forEach((diagnostic: ts.Diagnostic) => { + printDiagnostic(diagnostic, ErrorCodeModule.TSC, errorCodeLogger); + }); }); } diff --git a/compiler/src/interop/src/ets_checker.ts b/compiler/src/interop/src/ets_checker.ts index cf94e3828..9ac1b9d94 100644 --- a/compiler/src/interop/src/ets_checker.ts +++ b/compiler/src/interop/src/ets_checker.ts @@ -792,7 +792,7 @@ function processBuildHap(cacheFile: string, rootFileNames: string[], parentEvent if ((/\.d\.e?ts$/).test(moduleFile)) { generateSourceFilesInHar(moduleFile, fs.readFileSync(moduleFile, 'utf-8'), path.extname(moduleFile), projectConfig, projectConfig.modulePathMap); - } else if ((/\.e?ts$/).test(moduleFile)) { + } else if ((/\.e?ts$/).test(moduleFile) && !toUnixPath(moduleFile).includes('/oh_modules/')) { emit = undefined; let sourcefile = globalProgram.program.getSourceFile(moduleFile); if (sourcefile) { @@ -810,8 +810,16 @@ function processBuildHap(cacheFile: string, rootFileNames: string[], parentEvent } function printDeclarationDiagnostics(errorCodeLogger?: Object | undefined): void { - globalProgram.builderProgram.getDeclarationDiagnostics().forEach((diagnostic: ts.Diagnostic) => { - printDiagnostic(diagnostic, ErrorCodeModule.TSC, errorCodeLogger); + globalProgram.program.getSourceFiles().forEach((sourceFile: ts.SourceFile) => { + if ((/\.d\.e?ts$/).test(sourceFile.fileName) || (/\.js$/).test(sourceFile.fileName)) { + return; + } + if (toUnixPath(sourceFile.fileName).includes('/oh_modules/')) { + return; + } + globalProgram.builderProgram.getDeclarationDiagnostics(sourceFile).forEach((diagnostic: ts.Diagnostic) => { + printDiagnostic(diagnostic, ErrorCodeModule.TSC, errorCodeLogger); + }); }); } -- Gitee