From f46f0bfbb539e5c8c38c0689e83552db4bf90817 Mon Sep 17 00:00:00 2001 From: fanglou Date: Wed, 18 Jun 2025 23:09:26 +0800 Subject: [PATCH] fix migration helper migrate issue Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICG6LO Signed-off-by: fanglou Change-Id: Ia781f29f8c76014e5769334142a0ef092e7dd504 --- ets2panda/linter/src/cli/CommandLineParser.ts | 4 +++- ets2panda/linter/src/lib/LinterRunner.ts | 20 ++++++++----------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/ets2panda/linter/src/cli/CommandLineParser.ts b/ets2panda/linter/src/cli/CommandLineParser.ts index 9849eedf17..9b52fbf15d 100644 --- a/ets2panda/linter/src/cli/CommandLineParser.ts +++ b/ets2panda/linter/src/cli/CommandLineParser.ts @@ -159,7 +159,9 @@ function formArkts2Options(cmdOptions: CommandLineOptions, commanderOpts: Option function formCommandLineOptions(parsedCmd: ParsedCommand): CommandLineOptions { const opts: CommandLineOptions = { - inputFiles: parsedCmd.args.inputFiles, + inputFiles: parsedCmd.args.inputFiles.map((file) => { + return path.normalize(file); + }), linterOptions: { useRtLogic: true, interopCheckMode: false diff --git a/ets2panda/linter/src/lib/LinterRunner.ts b/ets2panda/linter/src/lib/LinterRunner.ts index 453731f7bc..308bb60310 100644 --- a/ets2panda/linter/src/lib/LinterRunner.ts +++ b/ets2panda/linter/src/lib/LinterRunner.ts @@ -209,16 +209,9 @@ function fix( ): boolean { const program = linterConfig.tscCompiledProgram.getProgram(); let appliedFix = false; - const mergedProblems = lintResult.problemsInfos; - if (hcResults !== undefined) { - for (const [filePath, problems] of hcResults) { - if (mergedProblems.has(filePath)) { - mergedProblems.get(filePath)!.push(...problems); - } else { - mergedProblems.set(filePath, problems); - } - } - } + // Apply homecheck fixes first to avoid them being skipped due to conflict with linter autofixes + let mergedProblems: Map = hcResults ?? new Map(); + mergedProblems = mergeArrayMaps(mergedProblems, lintResult.problemsInfos); mergedProblems.forEach((problemInfos, fileName) => { const srcFile = program.getSourceFile(fileName); if (!srcFile) { @@ -231,7 +224,8 @@ function fix( linterConfig.cmdOptions.linterOptions.arkts2 && linterConfig.cmdOptions.inputFiles.includes(fileName) && !hasUseStaticDirective(srcFile) && - linterConfig.cmdOptions.linterOptions.ideInteractive; + linterConfig.cmdOptions.linterOptions.ideInteractive && + !qEd.QuasiEditor.hasAnyAutofixes(problemInfos); // If nothing to fix or don't need to add 'use static', then skip file if (!qEd.QuasiEditor.hasAnyAutofixes(problemInfos) && !needToAddUseStatic) { return; @@ -244,7 +238,9 @@ function fix( linterConfig.cmdOptions.outputFilePath ); updatedSourceTexts.set(fileName, qe.fix(problemInfos, needToAddUseStatic)); - appliedFix = true; + if (!needToAddUseStatic) { + appliedFix = true; + } }); return appliedFix; -- Gitee