From 2b70f653d0ed60cf99876b7f8846a10c7fb39167 Mon Sep 17 00:00:00 2001 From: enxue Date: Thu, 11 Sep 2025 17:35:17 +0800 Subject: [PATCH] add atomError filter Signed-off-by: enxue --- compiler/src/ets_checker.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/compiler/src/ets_checker.ts b/compiler/src/ets_checker.ts index 97422740d..56a9aefc5 100644 --- a/compiler/src/ets_checker.ts +++ b/compiler/src/ets_checker.ts @@ -105,6 +105,7 @@ import { import { ErrorCodeModule } from './hvigor_error_code/const/error_code_module'; import { buildErrorInfoFromDiagnostic } from './hvigor_error_code/utils'; import { concatenateEtsOptions, getExternalComponentPaths } from './external_component_map'; +import { ATOMICSERVICE_BUNDLE_TYPE } from './fast_build/system_api/api_check_define'; export interface LanguageServiceCache { service?: ts.LanguageService; @@ -849,6 +850,11 @@ function containFormError(message: string): boolean { return false; } +function matchJSGrammarErrorMessage(message: string): boolean { + const regex = /^'.*?' can't support atomicservice application\.$/; + return regex.test(message); +} + let fileToIgnoreDiagnostics: Set | undefined = undefined; function collectFileToThrowDiagnostics(file: string, fileToThrowDiagnostics: Set): void { @@ -928,12 +934,27 @@ export function printDiagnostic(diagnostic: ts.Diagnostic, flag?: ErrorCodeModul return; } + if (fileToIgnoreDiagnostics) { + fileToIgnoreDiagnostics.forEach(fileName => { + if (!isInSDK(fileName) && projectConfig.bundleType === ATOMICSERVICE_BUNDLE_TYPE && + (/\.(c|m)?js$/).test(fileName) && + (fileName.replace(/\\/g, '/').startsWith(projectConfig.projectPath.replace(/\\/g, '/')))) { + fileToIgnoreDiagnostics.delete(fileName); + } + }); + } + if (fileToIgnoreDiagnostics && diagnostic.file && diagnostic.file.fileName && fileToIgnoreDiagnostics.has(toUnixPath(diagnostic.file.fileName))) { return; } const message: string = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n'); + + if (!matchJSGrammarErrorMessage(message)) { + return; + } + if (validateError(message)) { if (process.env.watchMode !== 'true' && !projectConfig.xtsMode) { updateErrorFileCache(diagnostic); -- Gitee