From db6628fb038596f0813c8c06d82d30924b6d7556 Mon Sep 17 00:00:00 2001 From: zhongning Date: Tue, 1 Jul 2025 14:26:36 +0800 Subject: [PATCH] fix bug for UseConcurrentDeprecated Issue:https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICJ19K Test scenarios:new tests update to the linter Signed-off-by: zhongning --- ets2panda/linter/src/lib/TypeScriptLinter.ts | 2 +- .../concurrent/use_limited_and_concurrent.ets | 13 +++++ ...use_limited_and_concurrent.ets.arkts2.json | 22 +++++++- ...se_limited_and_concurrent.ets.autofix.json | 56 ++++++++++++++++++- ...use_limited_and_concurrent.ets.migrate.ets | 13 +++++ 5 files changed, 101 insertions(+), 5 deletions(-) diff --git a/ets2panda/linter/src/lib/TypeScriptLinter.ts b/ets2panda/linter/src/lib/TypeScriptLinter.ts index 0b7067a939..14e8960641 100644 --- a/ets2panda/linter/src/lib/TypeScriptLinter.ts +++ b/ets2panda/linter/src/lib/TypeScriptLinter.ts @@ -7542,7 +7542,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } const text = stringLiteral.text; - const autofix = this.autofixer?.removeNode(stringLiteral); + const autofix = this.autofixer?.removeNode(stringLiteral.parent); if (text === USE_CONCURRENT) { this.incrementCounters(stringLiteral, FaultID.UseConcurrentDeprecated, autofix); diff --git a/ets2panda/linter/test/concurrent/use_limited_and_concurrent.ets b/ets2panda/linter/test/concurrent/use_limited_and_concurrent.ets index 22ef20b645..6e6dfcec02 100644 --- a/ets2panda/linter/test/concurrent/use_limited_and_concurrent.ets +++ b/ets2panda/linter/test/concurrent/use_limited_and_concurrent.ets @@ -39,3 +39,16 @@ switch (variable2) { case 'use shared': break; } + +function refreshToGetFontScale(): number { + 'use concurrent'; + const TAG = 'SCBScreenLock-refreshToGetFontScale'; + const log: LogHelper = LogHelper.getLogHelper(LogDomain.KG, TAG); + const FONT_SCALE_DEFAULT: number = 1; + try { + return uiAppearance.getFontScale(); + } catch (err) { + log.showError(`uiAppearance getFontScale err,code:${err?.code}`); + } + return FONT_SCALE_DEFAULT; +} diff --git a/ets2panda/linter/test/concurrent/use_limited_and_concurrent.ets.arkts2.json b/ets2panda/linter/test/concurrent/use_limited_and_concurrent.ets.arkts2.json index 0a82914a53..e660719da9 100644 --- a/ets2panda/linter/test/concurrent/use_limited_and_concurrent.ets.arkts2.json +++ b/ets2panda/linter/test/concurrent/use_limited_and_concurrent.ets.arkts2.json @@ -43,6 +43,26 @@ "suggest": "", "rule": "\"use concurrent\" is not supported (arkts-limited-stdlib-no-use-concurrent)", "severity": "ERROR" + }, + { + "line": 44, + "column": 3, + "endLine": 44, + "endColumn": 19, + "problem": "UseConcurrentDeprecated", + "suggest": "", + "rule": "\"use concurrent\" is not supported (arkts-limited-stdlib-no-use-concurrent)", + "severity": "ERROR" + }, + { + "line": 47, + "column": 38, + "endLine": 47, + "endColumn": 39, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" } ] -} +} \ No newline at end of file diff --git a/ets2panda/linter/test/concurrent/use_limited_and_concurrent.ets.autofix.json b/ets2panda/linter/test/concurrent/use_limited_and_concurrent.ets.autofix.json index 052fc5f382..de41dd6541 100644 --- a/ets2panda/linter/test/concurrent/use_limited_and_concurrent.ets.autofix.json +++ b/ets2panda/linter/test/concurrent/use_limited_and_concurrent.ets.autofix.json @@ -24,7 +24,11 @@ { "start": 605, "end": 617, - "replacementText": "" + "replacementText": "", + "line": 16, + "column": 1, + "endLine": 16, + "endColumn": 13 } ], "suggest": "", @@ -51,12 +55,58 @@ { "start": 687, "end": 703, - "replacementText": "" + "replacementText": "", + "line": 20, + "column": 5, + "endLine": 20, + "endColumn": 21 } ], "suggest": "", "rule": "\"use concurrent\" is not supported (arkts-limited-stdlib-no-use-concurrent)", "severity": "ERROR" + }, + { + "line": 44, + "column": 3, + "endLine": 44, + "endColumn": 19, + "problem": "UseConcurrentDeprecated", + "autofix": [ + { + "start": 1019, + "end": 1036, + "replacementText": "", + "line": 44, + "column": 3, + "endLine": 44, + "endColumn": 19 + } + ], + "suggest": "", + "rule": "\"use concurrent\" is not supported (arkts-limited-stdlib-no-use-concurrent)", + "severity": "ERROR" + }, + { + "line": 47, + "column": 38, + "endLine": 47, + "endColumn": 39, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1195, + "end": 1196, + "replacementText": "1.0", + "line": 47, + "column": 38, + "endLine": 47, + "endColumn": 39 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" } ] -} +} \ No newline at end of file diff --git a/ets2panda/linter/test/concurrent/use_limited_and_concurrent.ets.migrate.ets b/ets2panda/linter/test/concurrent/use_limited_and_concurrent.ets.migrate.ets index 5224e3b79f..315ac75338 100644 --- a/ets2panda/linter/test/concurrent/use_limited_and_concurrent.ets.migrate.ets +++ b/ets2panda/linter/test/concurrent/use_limited_and_concurrent.ets.migrate.ets @@ -39,3 +39,16 @@ switch (variable2) { case 'use shared': break; } + +function refreshToGetFontScale(): number { + + const TAG = 'SCBScreenLock-refreshToGetFontScale'; + const log: LogHelper = LogHelper.getLogHelper(LogDomain.KG, TAG); + const FONT_SCALE_DEFAULT: number = 1.0; + try { + return uiAppearance.getFontScale(); + } catch (err) { + log.showError(`uiAppearance getFontScale err,code:${err?.code}`); + } + return FONT_SCALE_DEFAULT; +} -- Gitee