diff --git a/ets2panda/linter/src/lib/TypeScriptLinter.ts b/ets2panda/linter/src/lib/TypeScriptLinter.ts index 7a6dd23d96c159848928bf3d1454328e93c1db4e..71cba568429c6ca438f73d115318862202a07016 100644 --- a/ets2panda/linter/src/lib/TypeScriptLinter.ts +++ b/ets2panda/linter/src/lib/TypeScriptLinter.ts @@ -50,7 +50,8 @@ import { SENDABLE_DECORATOR, SENDABLE_DECORATOR_NODES, SENDABLE_FUNCTION_UNSUPPORTED_STAGES_IN_API12, - SENDBALE_FUNCTION_START_VERSION + SENDBALE_FUNCTION_START_VERSION, + TASKPOOL } from './utils/consts/SendableAPI'; import { DEFAULT_COMPATIBLE_SDK_VERSION, DEFAULT_COMPATIBLE_SDK_VERSION_STAGE } from './utils/consts/VersionInfo'; import { forEachNodeInSubtree } from './utils/functions/ForEachNodeInSubtree'; @@ -141,6 +142,7 @@ import { NUMBER_LITERAL } from './utils/consts/RuntimeCheckAPI'; import { globalApiAssociatedInfo } from './utils/consts/AssociatedInfo'; import { ARRAY_API_LIST } from './utils/consts/ArraysAPI'; import { ERROR_PROP_LIST } from './utils/consts/ErrorProp'; +import { D_ETS, D_TS } from './utils/consts/TsSuffix'; interface InterfaceSymbolTypeResult { propNames: string[]; @@ -1303,26 +1305,28 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { if (methodName !== ISCONCURRENT) { return; } - const moduleSpecifier = this.findModuleSpecifierforDepricatedIsConcurrent(node); - if (!moduleSpecifier || !ts.isStringLiteral(moduleSpecifier)) { + const symbol = this.tsUtils.trueSymbolAtLocation(node.expression); + if (!symbol) { return; } - if ( - TASKPOOL_MODULES.some((moduleName) => { - return TsUtils.removeOrReplaceQuotes(moduleSpecifier.getText(), false) === moduleName; - }) - ) { - this.incrementCounters(node.name, FaultID.IsConcurrentDeprecated); - } - } + if (symbol.name === TASKPOOL) { + const decl = TsUtils.getDeclaration(symbol); - findModuleSpecifierforDepricatedIsConcurrent(node: ts.PropertyAccessExpression): ts.Expression | undefined { - let symbol = this.tsUtils.trueSymbolAtLocation(node.expression); - if (symbol && 'unknown' === symbol.name) { - symbol = this.tsTypeChecker.getSymbolAtLocation(node.expression); + if (!decl) { + return; + } + + const sourceFile = decl.getSourceFile(); + const fileName = path.basename(sourceFile.fileName); + + if ( + TASKPOOL_MODULES.some((moduleName) => { + return fileName.startsWith(moduleName) && (fileName.endsWith(D_TS) || fileName.endsWith(D_ETS)); + }) + ) { + this.incrementCounters(node.name, FaultID.IsConcurrentDeprecated); + } } - const importDecl = ts.findAncestor(TsUtils.getDeclaration(symbol), ts.isImportDeclaration); - return importDecl?.moduleSpecifier; } checkFunctionProperty( diff --git a/ets2panda/linter/src/lib/utils/functions/ProcessWrite.ts b/ets2panda/linter/src/lib/utils/functions/ProcessWrite.ts index bb379f6f8383d98a7bbc23c598681a0b7622ea04..ef8e100ae8b34ba1feb582b9901d2a95fd55cf71 100644 --- a/ets2panda/linter/src/lib/utils/functions/ProcessWrite.ts +++ b/ets2panda/linter/src/lib/utils/functions/ProcessWrite.ts @@ -27,4 +27,4 @@ export async function processSyncErr(message: string): Promise { resolve('success'); }); }); -} \ No newline at end of file +} diff --git a/ets2panda/linter/test/concurrent/no_support_isconcurrent.ets.arkts2.json b/ets2panda/linter/test/concurrent/no_support_isconcurrent.ets.arkts2.json index 428032b2d86c83a7b126a00d005a4c9cc028e644..9b627b9d723d7f5d127d0724c1c125b3dfa719d3 100644 --- a/ets2panda/linter/test/concurrent/no_support_isconcurrent.ets.arkts2.json +++ b/ets2panda/linter/test/concurrent/no_support_isconcurrent.ets.arkts2.json @@ -23,6 +23,26 @@ "suggest": "", "rule": "Usage of standard library is restricted(arkts-limited-stdlib-no-concurrent-decorator)", "severity": "ERROR" + }, + { + "line": 23, + "column": 32, + "endLine": 23, + "endColumn": 44, + "problem": "IsConcurrentDeprecated", + "suggest": "", + "rule": "isConcurrent is not supported (arkts-limited-stdlib-no-support-isConcurrent)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 27, + "endLine": 25, + "endColumn": 39, + "problem": "IsConcurrentDeprecated", + "suggest": "", + "rule": "isConcurrent is not supported (arkts-limited-stdlib-no-support-isConcurrent)", + "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/concurrent/no_support_isconcurrent2.ets.arkts2.json b/ets2panda/linter/test/concurrent/no_support_isconcurrent2.ets.arkts2.json index b418f42b2130a303f51785ae4ec7b67abd0a67b4..bba96543288bcd93a29d4f09544654ae204a573f 100755 --- a/ets2panda/linter/test/concurrent/no_support_isconcurrent2.ets.arkts2.json +++ b/ets2panda/linter/test/concurrent/no_support_isconcurrent2.ets.arkts2.json @@ -24,26 +24,6 @@ "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", "severity": "ERROR" }, - { - "line": 23, - "column": 17, - "endLine": 23, - "endColumn": 29, - "problem": "IsConcurrentDeprecated", - "suggest": "", - "rule": "isConcurrent is not supported (arkts-limited-stdlib-no-support-isConcurrent)", - "severity": "ERROR" - }, - { - "line": 25, - "column": 12, - "endLine": 25, - "endColumn": 24, - "problem": "IsConcurrentDeprecated", - "suggest": "", - "rule": "isConcurrent is not supported (arkts-limited-stdlib-no-support-isConcurrent)", - "severity": "ERROR" - }, { "line": 25, "column": 25,