diff --git a/ets2panda/linter/src/cli/LinterCLI.ts b/ets2panda/linter/src/cli/LinterCLI.ts index e45d56a7d5513400fd06b8e040abbe7d258725b8..cfcb8b5f70e1fbb11eb63768a1de0843fd4f9a14 100644 --- a/ets2panda/linter/src/cli/LinterCLI.ts +++ b/ets2panda/linter/src/cli/LinterCLI.ts @@ -27,6 +27,7 @@ import { logStatistics } from '../lib/statistics/StatisticsLogger'; import { arkts2Rules, onlyArkts2SyntaxRules } from '../lib/utils/consts/ArkTS2Rules'; import { MigrationTool } from 'homecheck'; import { getHomeCheckConfigInfo, transferIssues2ProblemInfo } from '../lib/HomeCheck'; +import { processSyncErr, processSyncOut } from '../lib/utils/functions/ProcessWrite'; export function run(): void { const commandLineArgs = process.argv.slice(2); @@ -131,22 +132,6 @@ async function generateReportFile(reportData, reportPath?: string): Promise { - await new Promise((resolve) => { - process.stdout.write(message, () => { - resolve('success'); - }); - }); -} - -async function processSyncErr(message: string): Promise { - await new Promise((resolve) => { - process.stderr.write(message, () => { - resolve('success'); - }); - }); -} - function getTempFileName(): string { return path.join(os.tmpdir(), Math.floor(Math.random() * 10000000).toString() + '_linter_tmp_file.ts'); } diff --git a/ets2panda/linter/src/lib/LinterRunner.ts b/ets2panda/linter/src/lib/LinterRunner.ts index 453731f7bcaf14ae41e51d199c22b75f73572acb..e673595da5185b7a5d23443d880af9db1976b4ba 100644 --- a/ets2panda/linter/src/lib/LinterRunner.ts +++ b/ets2panda/linter/src/lib/LinterRunner.ts @@ -41,6 +41,7 @@ import { compileLintOptions } from './ts-compiler/Compiler'; import * as qEd from './autofixes/QuasiEditor'; import { ProjectStatistics } from './statistics/ProjectStatistics'; import type { BaseTypeScriptLinter } from './BaseTypeScriptLinter'; +import { processSyncErr } from '../lib/utils/functions/ProcessWrite'; function prepareInputFilesList(cmdOptions: CommandLineOptions): string[] { let inputFiles = cmdOptions.inputFiles.map((x) => { @@ -129,6 +130,7 @@ function lintFiles( TypeScriptLinter.initGlobals(); InteropTypescriptLinter.initGlobals(); + let fileCount: number = 0; for (const srcFile of srcFiles) { const linter: BaseTypeScriptLinter = !options.interopCheckMode ? @@ -138,6 +140,10 @@ function lintFiles( const problems = linter.problemsInfos; problemsInfos.set(path.normalize(srcFile.fileName), [...problems]); projectStats.fileStats.push(linter.fileStats); + fileCount = fileCount + 1; + if (options.ideInteractive) { + processSyncErr(`{"content":"${srcFile.fileName}","messageType":1,"indicator":${fileCount / srcFiles.length}}\n`); + } } return { diff --git a/ets2panda/linter/src/lib/utils/functions/ProcessWrite.ts b/ets2panda/linter/src/lib/utils/functions/ProcessWrite.ts new file mode 100644 index 0000000000000000000000000000000000000000..bb379f6f8383d98a7bbc23c598681a0b7622ea04 --- /dev/null +++ b/ets2panda/linter/src/lib/utils/functions/ProcessWrite.ts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export async function processSyncOut(message: string): Promise { + await new Promise((resolve) => { + process.stdout.write(message, () => { + resolve('success'); + }); + }); +} + +export async function processSyncErr(message: string): Promise { + await new Promise((resolve) => { + process.stderr.write(message, () => { + resolve('success'); + }); + }); +} \ No newline at end of file