diff --git a/ets2panda/linter/src/lib/TypeScriptLinter.ts b/ets2panda/linter/src/lib/TypeScriptLinter.ts index 1e0dd75815109e868dd9b34384f35e41c0523c98..2c0f8f9ece2b95629ab572be45269aabd551a055 100644 --- a/ets2panda/linter/src/lib/TypeScriptLinter.ts +++ b/ets2panda/linter/src/lib/TypeScriptLinter.ts @@ -87,12 +87,8 @@ import { BUILTIN_GENERIC_CONSTRUCTORS } from './utils/consts/BuiltinGenericConst import { DEFAULT_DECORATOR_WHITE_LIST } from './utils/consts/DefaultDecoratorWhitelist'; import { INVALID_IDENTIFIER_KEYWORDS } from './utils/consts/InValidIndentifierKeywords'; import { WORKER_MODULES, WORKER_TEXT } from './utils/consts/WorkerAPI'; -import { - COLLECTIONS_TEXT, - COLLECTIONS_MODULES, - BIT_VECTOR, - ARKTS_COLLECTIONS_MODULE -} from './utils/consts/CollectionsAPI'; +import type { BitVectorUsage } from './utils/consts/CollectionsAPI'; +import { COLLECTIONS_TEXT, COLLECTIONS_MODULES, BIT_VECTOR } from './utils/consts/CollectionsAPI'; import { ASON_TEXT, ASON_MODULES, ARKTS_UTILS_TEXT, JSON_TEXT, ASON_WHITE_SET } from './utils/consts/ArkTSUtilsAPI'; import { interanlFunction } from './utils/consts/InternalFunction'; import { ETS_PART, PATH_SEPARATOR } from './utils/consts/OhmUrl'; @@ -3875,7 +3871,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { }) || false; const classType: ts.Type | undefined = this.getClassType(classDecl, isStatic); const allBaseTypes = classType && this.getAllBaseTypes(classType, classDecl, isStatic); - + if (!allBaseTypes || allBaseTypes.length === 0) { return; } @@ -4113,7 +4109,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { for (let i = 0; i < Math.min(derivedParams.length, baseParams.length); i++) { const baseParam = baseParams[i]; const derivedParam = derivedParams[i]; - + if (!baseParam.questionToken && derivedParam.questionToken) { this.incrementCounters(derivedParam, FaultID.MethodInheritRule); return; @@ -8446,21 +8442,10 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { if (!ts.isIdentifier(ident)) { return; } - const importBitVectorAutofix = this.checkBitVector(ident); - const replace = this.autofixer?.replaceNode(node, ident.getText()); - let autofix: Autofix[] | undefined = []; - - if (replace) { - autofix = replace; - } - - if (importBitVectorAutofix) { - autofix.push(importBitVectorAutofix); - } - - if (autofix.length === 0) { - autofix = undefined; + if (this.isBitVector(ident)) { + return; } + const autofix = this.autofixer?.replaceNode(node, ident.getText()); this.incrementCounters(node, FaultID.NoNeedStdLibSendableContainer, autofix); } @@ -8489,9 +8474,19 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } if (ts.isImportSpecifier(parent) && ts.isIdentifier(node)) { + const bitVectorUsed = this.checkBitVector(node.getSourceFile()); + + if (bitVectorUsed?.used) { + const ns = bitVectorUsed.ns; + if (parent.name.text === ns) { + return; + } + } + if (parent.propertyName && node.text === parent.propertyName.text) { return; } + const autofix = this.autofixer?.removeImport(node, parent); this.incrementCounters(node, FaultID.NoNeedStdLibSendableContainer, autofix); } @@ -8558,29 +8553,28 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } } - private checkBitVector(ident: ts.Identifier): Autofix | undefined { - if (!this.isBitVector(ident)) { - return undefined; - } + private checkBitVector(node: ts.Node): BitVectorUsage { + if (!ts.isIdentifier(node)) { + let isBitVector: BitVectorUsage; + node.forEachChild((child) => { + const checked = this.checkBitVector(child); + if (checked?.used) { + isBitVector = checked; + } + }); - let lastImportDeclaration: ts.Node | undefined; - let bitVectorImported: boolean = false; - for (const node of this.sourceFile.statements) { - if (!ts.isImportDeclaration(node)) { - continue; - } - lastImportDeclaration = node; + return isBitVector; + } - if (this.checkImportDeclarationForBitVector(node)) { - bitVectorImported = true; - } + if (!this.isBitVector(node)) { + return { ns: '', used: false }; } - if (bitVectorImported) { + if (!ts.isPropertyAccessExpression(node.parent)) { return undefined; } - return this.autofixer?.importBitVector(ident, lastImportDeclaration); + return { ns: node.parent.expression.getText(), used: true }; } private isBitVector(ident: ts.Identifier): boolean { @@ -8589,33 +8583,6 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return ident.text === BIT_VECTOR; } - private checkImportDeclarationForBitVector(node: ts.ImportDeclaration): boolean { - const importSpecifier = node.moduleSpecifier; - if (!ts.isStringLiteral(importSpecifier)) { - return false; - } - const importSpecifierText = importSpecifier.text; - - const importClause = node.importClause; - if (!importClause) { - return false; - } - - const namedBindings = importClause.namedBindings; - if (!namedBindings || !ts.isNamedImports(namedBindings)) { - return false; - } - - let bitVectorImported = false; - for (const specifier of namedBindings.elements) { - if (this.isBitVector(specifier.name) && importSpecifierText === ARKTS_COLLECTIONS_MODULE) { - bitVectorImported = true; - } - } - - return bitVectorImported; - } - interfacesNeedToAlarm: ts.Identifier[] = []; interfacesNeedToImport: Set = new Set(); interfacesAlreadyImported: Set = new Set(); @@ -10281,6 +10248,14 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } for (const spec of forbiddenNamed) { + const bitVectorUsed = this.checkBitVector(spec.getSourceFile()); + + if (bitVectorUsed?.used) { + const ns = bitVectorUsed.ns; + if (spec.name.text === ns) { + continue; + } + } const autofix = this.autofixer?.removeImportSpecifier(spec, importDeclaration); this.incrementCounters(spec, FaultID.LimitedStdLibNoImportConcurrency, autofix); } @@ -13551,8 +13526,8 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } if ( - (ts.isIdentifier(typeRef.typeName) && typeRef.typeName.text === ES_OBJECT) || - (ts.isQualifiedName(typeRef.typeName) && typeRef.typeName.right.text === ES_OBJECT) + ts.isIdentifier(typeRef.typeName) && typeRef.typeName.text === ES_OBJECT || + ts.isQualifiedName(typeRef.typeName) && typeRef.typeName.right.text === ES_OBJECT ) { this.incrementCounters(typeRef, FaultID.NoESObjectSupport); } diff --git a/ets2panda/linter/src/lib/utils/consts/CollectionsAPI.ts b/ets2panda/linter/src/lib/utils/consts/CollectionsAPI.ts index 331a36bb29639f47336a980fbe78db1f32e6ab0f..447620d50e90fa86cd474f73c9baa192cf6db826 100644 --- a/ets2panda/linter/src/lib/utils/consts/CollectionsAPI.ts +++ b/ets2panda/linter/src/lib/utils/consts/CollectionsAPI.ts @@ -17,3 +17,5 @@ export const COLLECTIONS_TEXT = 'collections'; export const ARKTS_COLLECTIONS_MODULE = '@arkts.collections'; export const BIT_VECTOR = 'BitVector'; export const COLLECTIONS_MODULES = ['@arkts.collections', '@kit.ArkTS']; + +export type BitVectorUsage = undefined | { ns: string; used: boolean }; diff --git a/ets2panda/linter/test/main/collections_module.ets.arkts2.json b/ets2panda/linter/test/main/collections_module.ets.arkts2.json index 1bba4e4725cf6a81e3a62a9e4e5816374c46b46c..907c68b5d5f2b86b1b634f52e1084d9d3a9f6068 100644 --- a/ets2panda/linter/test/main/collections_module.ets.arkts2.json +++ b/ets2panda/linter/test/main/collections_module.ets.arkts2.json @@ -14,16 +14,6 @@ "limitations under the License." ], "result": [ - { - "line": 16, - "column": 10, - "endLine": 16, - "endColumn": 21, - "problem": "NoNeedStdLibSendableContainer", - "suggest": "", - "rule": "Sendable containers are not supported (arkts-no-need-stdlib-sendable-containers)", - "severity": "ERROR" - }, { "line": 18, "column": 25, @@ -174,16 +164,6 @@ "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)", "severity": "ERROR" }, - { - "line": 44, - "column": 28, - "endLine": 44, - "endColumn": 49, - "problem": "NoNeedStdLibSendableContainer", - "suggest": "", - "rule": "Sendable containers are not supported (arkts-no-need-stdlib-sendable-containers)", - "severity": "ERROR" - }, { "line": 45, "column": 11, @@ -203,16 +183,6 @@ "suggest": "", "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", "severity": "ERROR" - }, - { - "line": 45, - "column": 27, - "endLine": 45, - "endColumn": 48, - "problem": "NoNeedStdLibSendableContainer", - "suggest": "", - "rule": "Sendable containers are not supported (arkts-no-need-stdlib-sendable-containers)", - "severity": "ERROR" } ] -} +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/collections_module.ets.autofix.json b/ets2panda/linter/test/main/collections_module.ets.autofix.json index b09314b3c667efad6a5f3eeec7843e6b7839e5be..f16eb0e4d1b621806a36343563f2e7031dfe7185 100644 --- a/ets2panda/linter/test/main/collections_module.ets.autofix.json +++ b/ets2panda/linter/test/main/collections_module.ets.autofix.json @@ -14,27 +14,6 @@ "limitations under the License." ], "result": [ - { - "line": 16, - "column": 10, - "endLine": 16, - "endColumn": 21, - "problem": "NoNeedStdLibSendableContainer", - "autofix": [ - { - "start": 605, - "end": 667, - "replacementText": "", - "line": 16, - "column": 10, - "endLine": 16, - "endColumn": 21 - } - ], - "suggest": "", - "rule": "Sendable containers are not supported (arkts-no-need-stdlib-sendable-containers)", - "severity": "ERROR" - }, { "line": 18, "column": 25, @@ -306,36 +285,6 @@ "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)", "severity": "ERROR" }, - { - "line": 44, - "column": 28, - "endLine": 44, - "endColumn": 49, - "problem": "NoNeedStdLibSendableContainer", - "autofix": [ - { - "start": 1514, - "end": 1535, - "replacementText": "BitVector", - "line": 44, - "column": 28, - "endLine": 44, - "endColumn": 49 - }, - { - "start": 919, - "end": 919, - "replacementText": "\nimport { BitVector } from \"@arkts.collections\";\n", - "line": 44, - "column": 28, - "endLine": 44, - "endColumn": 49 - } - ], - "suggest": "", - "rule": "Sendable containers are not supported (arkts-no-need-stdlib-sendable-containers)", - "severity": "ERROR" - }, { "line": 45, "column": 11, @@ -355,36 +304,6 @@ "suggest": "", "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", "severity": "ERROR" - }, - { - "line": 45, - "column": 27, - "endLine": 45, - "endColumn": 48, - "problem": "NoNeedStdLibSendableContainer", - "autofix": [ - { - "start": 1573, - "end": 1594, - "replacementText": "BitVector", - "line": 45, - "column": 27, - "endLine": 45, - "endColumn": 48 - }, - { - "start": 919, - "end": 919, - "replacementText": "\nimport { BitVector } from \"@arkts.collections\";\n", - "line": 45, - "column": 27, - "endLine": 45, - "endColumn": 48 - } - ], - "suggest": "", - "rule": "Sendable containers are not supported (arkts-no-need-stdlib-sendable-containers)", - "severity": "ERROR" } ] -} +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/collections_module.ets.migrate.ets b/ets2panda/linter/test/main/collections_module.ets.migrate.ets index 9915905ea53f6be768dfe0ad9871dd9059a031a9..9177530483c23fa21bc07a3f0c7955cb9348ce99 100644 --- a/ets2panda/linter/test/main/collections_module.ets.migrate.ets +++ b/ets2panda/linter/test/main/collections_module.ets.migrate.ets @@ -13,15 +13,13 @@ * limitations under the License. */ +import { collections } from './oh_modules/@arkts.collections'; - -import { collections as definedCollections } from './ignore_files/user_defined_collections'; -import { BitVector } from "@arkts.collections"; - //legal +import { collections as definedCollections } from './ignore_files/user_defined_collections'; //legal function tesCollectionsUsage() { @@ -43,6 +41,6 @@ function test(array: Array) { const map = Map(); } -function testBitVector(bv: BitVector) { - const bitVector = new BitVector(); +function testBitVector(bv: collections.BitVector) { + const bitVector = new collections.BitVector(); } diff --git a/ets2panda/linter/test/main/collections_module.ets.migrate.json b/ets2panda/linter/test/main/collections_module.ets.migrate.json index ad165a2fcbcd0041abbb65ea2032362ac99a168c..5a14ab57e1f22b27528a2071c35d9a880e9a13c7 100644 --- a/ets2panda/linter/test/main/collections_module.ets.migrate.json +++ b/ets2panda/linter/test/main/collections_module.ets.migrate.json @@ -13,56 +13,56 @@ "See the License for the specific language governing permissions and", "limitations under the License." ], - "result": [ - { - "line": 34, - "column": 7, - "endLine": 34, - "endColumn": 19, - "problem": "VariableMissingInitializer", - "suggest": "", - "rule": "After a variable is declared, a value must be assigned before using it (arkts-var-assignment-before-use)", - "severity": "ERROR" - }, - { - "line": 38, - "column": 7, - "endLine": 38, - "endColumn": 19, - "problem": "VariableMissingInitializer", - "suggest": "", - "rule": "After a variable is declared, a value must be assigned before using it (arkts-var-assignment-before-use)", - "severity": "ERROR" - }, - { - "line": 43, - "column": 11, - "endLine": 43, - "endColumn": 38, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 47, - "column": 11, - "endLine": 47, - "endColumn": 46, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 47, - "column": 27, - "endLine": 47, - "endColumn": 36, - "problem": "DynamicCtorCall", - "suggest": "", - "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", - "severity": "ERROR" - } - ] -} + "result": [ + { + "line": 32, + "column": 7, + "endLine": 32, + "endColumn": 19, + "problem": "VariableMissingInitializer", + "suggest": "", + "rule": "After a variable is declared, a value must be assigned before using it (arkts-var-assignment-before-use)", + "severity": "ERROR" + }, + { + "line": 36, + "column": 7, + "endLine": 36, + "endColumn": 19, + "problem": "VariableMissingInitializer", + "suggest": "", + "rule": "After a variable is declared, a value must be assigned before using it (arkts-var-assignment-before-use)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 11, + "endLine": 41, + "endColumn": 38, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 45, + "column": 11, + "endLine": 45, + "endColumn": 58, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 45, + "column": 27, + "endLine": 45, + "endColumn": 48, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/no_import_concurrency.ets.arkts2.json b/ets2panda/linter/test/main/no_import_concurrency.ets.arkts2.json index f23fdd92f6b74c9170ea2a05d90a0ac754077976..d42284c09339a4b72174dd15e3b345ddd67a1be4 100644 --- a/ets2panda/linter/test/main/no_import_concurrency.ets.arkts2.json +++ b/ets2panda/linter/test/main/no_import_concurrency.ets.arkts2.json @@ -1,168 +1,168 @@ { - "copyright": [ - "Copyright (c) 2025 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." - ], - "result": [ - { - "line": 17, - "column": 21, - "endLine": 17, - "endColumn": 36, - "problem": "LimitedStdLibNoImportConcurrency", - "suggest": "", - "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", - "severity": "ERROR" - }, - { - "line": 19, - "column": 8, - "endLine": 19, - "endColumn": 12, - "problem": "LimitedStdLibNoImportConcurrency", - "suggest": "", - "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", - "severity": "ERROR" - }, - { - "line": 20, - "column": 25, - "endLine": 20, - "endColumn": 42, - "problem": "LimitedStdLibNoImportConcurrency", - "suggest": "", - "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", - "severity": "ERROR" - }, - { - "line": 21, - "column": 15, - "endLine": 21, - "endColumn": 32, - "problem": "LimitedStdLibNoImportConcurrency", - "suggest": "", - "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", - "severity": "ERROR" - }, - { - "line": 21, - "column": 34, - "endLine": 21, - "endColumn": 47, - "problem": "LimitedStdLibNoImportConcurrency", - "suggest": "", - "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", - "severity": "ERROR" - }, - { - "line": 23, - "column": 16, - "endLine": 23, - "endColumn": 31, - "problem": "LimitedStdLibNoImportConcurrency", - "suggest": "", - "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", - "severity": "ERROR" - }, - { - "line": 23, - "column": 33, - "endLine": 23, - "endColumn": 47, - "problem": "LimitedStdLibNoImportConcurrency", - "suggest": "", - "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", - "severity": "ERROR" - }, - { - "line": 24, - "column": 8, - "endLine": 24, - "endColumn": 13, - "problem": "LimitedStdLibNoImportConcurrency", - "suggest": "", - "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", - "severity": "ERROR" - }, - { - "line": 25, - "column": 10, - "endLine": 25, - "endColumn": 23, - "problem": "LimitedStdLibNoImportConcurrency", - "suggest": "", - "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", - "severity": "ERROR" - }, - { - "line": 25, - "column": 25, - "endLine": 25, - "endColumn": 43, - "problem": "LimitedStdLibNoImportConcurrency", - "suggest": "", - "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", - "severity": "ERROR" - }, - { - "line": 26, - "column": 8, - "endLine": 26, - "endColumn": 15, - "problem": "LimitedStdLibNoImportConcurrency", - "suggest": "", - "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", - "severity": "ERROR" - }, - { - "line": 27, - "column": 8, - "endLine": 27, - "endColumn": 11, - "problem": "LimitedStdLibNoImportConcurrency", - "suggest": "", - "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", - "severity": "ERROR" - }, - { - "line": 28, - "column": 8, - "endLine": 28, - "endColumn": 12, - "problem": "LimitedStdLibNoImportConcurrency", - "suggest": "", - "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", - "severity": "ERROR" - }, - { - "line": 33, - "column": 11, - "endLine": 33, - "endColumn": 20, - "problem": "NumericSemantics", - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 33, - "column": 17, - "endLine": 33, - "endColumn": 20, - "problem": "NumericSemantics", - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - } - ] -} + "copyright": [ + "Copyright (c) 2025 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." + ], + "result": [ + { + "line": 17, + "column": 21, + "endLine": 17, + "endColumn": 36, + "problem": "LimitedStdLibNoImportConcurrency", + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 8, + "endLine": 19, + "endColumn": 12, + "problem": "LimitedStdLibNoImportConcurrency", + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 25, + "endLine": 20, + "endColumn": 42, + "problem": "LimitedStdLibNoImportConcurrency", + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 15, + "endLine": 21, + "endColumn": 32, + "problem": "LimitedStdLibNoImportConcurrency", + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 34, + "endLine": 21, + "endColumn": 47, + "problem": "LimitedStdLibNoImportConcurrency", + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 16, + "endLine": 23, + "endColumn": 31, + "problem": "LimitedStdLibNoImportConcurrency", + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 33, + "endLine": 23, + "endColumn": 47, + "problem": "LimitedStdLibNoImportConcurrency", + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 8, + "endLine": 24, + "endColumn": 13, + "problem": "LimitedStdLibNoImportConcurrency", + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 10, + "endLine": 25, + "endColumn": 23, + "problem": "LimitedStdLibNoImportConcurrency", + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 25, + "endLine": 25, + "endColumn": 43, + "problem": "LimitedStdLibNoImportConcurrency", + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 8, + "endLine": 26, + "endColumn": 15, + "problem": "LimitedStdLibNoImportConcurrency", + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 8, + "endLine": 27, + "endColumn": 11, + "problem": "LimitedStdLibNoImportConcurrency", + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 8, + "endLine": 28, + "endColumn": 12, + "problem": "LimitedStdLibNoImportConcurrency", + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 11, + "endLine": 33, + "endColumn": 20, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 17, + "endLine": 33, + "endColumn": 20, + "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/main/no_import_concurrency.ets.migrate.json b/ets2panda/linter/test/main/no_import_concurrency.ets.migrate.json index 75faa009317be813e325733eb9cce302f88bbc8c..58b01f5a8aa1cfbc51947f0ce7fb35ad42c22595 100644 --- a/ets2panda/linter/test/main/no_import_concurrency.ets.migrate.json +++ b/ets2panda/linter/test/main/no_import_concurrency.ets.migrate.json @@ -35,4 +35,4 @@ "severity": "ERROR" } ] -} +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/property_access_by_index.ets.arkts2.json b/ets2panda/linter/test/main/property_access_by_index.ets.arkts2.json index d53752ee4808099169beec98c3ba007c4bf70fef..19c4e034ab7547217ae87130d622bb6196124517 100644 --- a/ets2panda/linter/test/main/property_access_by_index.ets.arkts2.json +++ b/ets2panda/linter/test/main/property_access_by_index.ets.arkts2.json @@ -14,16 +14,6 @@ "limitations under the License." ], "result": [ - { - "line": 16, - "column": 10, - "endLine": 16, - "endColumn": 21, - "problem": "NoNeedStdLibSendableContainer", - "suggest": "", - "rule": "Sendable containers are not supported (arkts-no-need-stdlib-sendable-containers)", - "severity": "ERROR" - }, { "line": 22, "column": 3, @@ -864,16 +854,6 @@ "rule": "Usage of standard library is restricted(arkts-limited-stdlib-no-sendable-decorator)", "severity": "ERROR" }, - { - "line": 177, - "column": 23, - "endLine": 177, - "endColumn": 44, - "problem": "NoNeedStdLibSendableContainer", - "suggest": "", - "rule": "Sendable containers are not supported (arkts-no-need-stdlib-sendable-containers)", - "severity": "ERROR" - }, { "line": 179, "column": 11, @@ -995,4 +975,4 @@ "severity": "ERROR" } ] -} +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/property_access_by_index.ets.autofix.json b/ets2panda/linter/test/main/property_access_by_index.ets.autofix.json index efd13151c42adb61ca4eccc3c89d3658bcbe0239..8a6496e8e74c00c6474656153e7eabbbfcaea5a0 100644 --- a/ets2panda/linter/test/main/property_access_by_index.ets.autofix.json +++ b/ets2panda/linter/test/main/property_access_by_index.ets.autofix.json @@ -14,27 +14,6 @@ "limitations under the License." ], "result": [ - { - "line": 16, - "column": 10, - "endLine": 16, - "endColumn": 21, - "problem": "NoNeedStdLibSendableContainer", - "autofix": [ - { - "start": 662, - "end": 713, - "replacementText": "", - "line": 16, - "column": 10, - "endLine": 16, - "endColumn": 21 - } - ], - "suggest": "", - "rule": "Sendable containers are not supported (arkts-no-need-stdlib-sendable-containers)", - "severity": "ERROR" - }, { "line": 22, "column": 3, @@ -1370,36 +1349,6 @@ "rule": "Usage of standard library is restricted(arkts-limited-stdlib-no-sendable-decorator)", "severity": "ERROR" }, - { - "line": 177, - "column": 23, - "endLine": 177, - "endColumn": 44, - "problem": "NoNeedStdLibSendableContainer", - "autofix": [ - { - "start": 3733, - "end": 3754, - "replacementText": "BitVector", - "line": 177, - "column": 23, - "endLine": 177, - "endColumn": 44 - }, - { - "start": 713, - "end": 713, - "replacementText": "\nimport { BitVector } from \"@arkts.collections\";\n", - "line": 177, - "column": 23, - "endLine": 177, - "endColumn": 44 - } - ], - "suggest": "", - "rule": "Sendable containers are not supported (arkts-no-need-stdlib-sendable-containers)", - "severity": "ERROR" - }, { "line": 179, "column": 11, @@ -1609,4 +1558,4 @@ "severity": "ERROR" } ] -} +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/property_access_by_index.ets.migrate.ets b/ets2panda/linter/test/main/property_access_by_index.ets.migrate.ets index 6a3cbe36afb397b39f328e127c7b0533ce69429e..2636387efc22a64927f70fd9046b92a07567aab1 100644 --- a/ets2panda/linter/test/main/property_access_by_index.ets.migrate.ets +++ b/ets2panda/linter/test/main/property_access_by_index.ets.migrate.ets @@ -13,9 +13,7 @@ * limitations under the License. */ import {OhosInterface} from './oh_modules/ohos_lib'; -import { BitVector } from "@arkts.collections"; - - +import { collections } from './@arkts.collections'; // #14071 class A { v: string = ''; @@ -176,11 +174,16 @@ mmap2['222']; mmap3["kkr"]; -class MyClass extends BitVector { + + + + +@Sendable +class MyClass extends collections.BitVector { constructor() { super(0.0); for (let i: number = 0.0; i < this.length; i++) { - this[i] = 1.0; + this[i as int] = 1.0; } } } diff --git a/ets2panda/linter/test/main/property_access_by_index.ets.migrate.json b/ets2panda/linter/test/main/property_access_by_index.ets.migrate.json index 12bd72ca456622b4c439c477985f0c361bcf2c04..ae9ec5691c7c3a7b2ce2a3ac23f57a07b4b38e08 100644 --- a/ets2panda/linter/test/main/property_access_by_index.ets.migrate.json +++ b/ets2panda/linter/test/main/property_access_by_index.ets.migrate.json @@ -15,9 +15,9 @@ ], "result": [ { - "line": 24, + "line": 22, "column": 3, - "endLine": 24, + "endLine": 22, "endColumn": 14, "problem": "PropertyAccessByIndex", "suggest": "", @@ -25,9 +25,9 @@ "severity": "ERROR" }, { - "line": 27, + "line": 25, "column": 10, - "endLine": 27, + "endLine": 25, "endColumn": 21, "problem": "PropertyAccessByIndex", "suggest": "", @@ -35,9 +35,9 @@ "severity": "ERROR" }, { - "line": 39, + "line": 37, "column": 1, - "endLine": 39, + "endLine": 37, "endColumn": 7, "problem": "RuntimeArrayCheck", "suggest": "", @@ -45,9 +45,9 @@ "severity": "ERROR" }, { - "line": 40, + "line": 38, "column": 1, - "endLine": 40, + "endLine": 38, "endColumn": 7, "problem": "RuntimeArrayCheck", "suggest": "", @@ -55,9 +55,9 @@ "severity": "ERROR" }, { - "line": 41, + "line": 39, "column": 1, - "endLine": 41, + "endLine": 39, "endColumn": 7, "problem": "RuntimeArrayCheck", "suggest": "", @@ -65,9 +65,9 @@ "severity": "ERROR" }, { - "line": 48, + "line": 46, "column": 3, - "endLine": 48, + "endLine": 46, "endColumn": 9, "problem": "PropertyAccessByIndex", "suggest": "", @@ -75,9 +75,9 @@ "severity": "ERROR" }, { - "line": 52, + "line": 50, "column": 3, - "endLine": 52, + "endLine": 50, "endColumn": 9, "problem": "PropertyAccessByIndex", "suggest": "", @@ -85,9 +85,9 @@ "severity": "ERROR" }, { - "line": 59, + "line": 57, "column": 5, - "endLine": 59, + "endLine": 57, "endColumn": 29, "problem": "AnyType", "suggest": "", @@ -95,15 +95,35 @@ "severity": "ERROR" }, { - "line": 59, + "line": 57, "column": 14, - "endLine": 59, + "endLine": 57, "endColumn": 29, "problem": "GenericCallNoTypeArgs", "suggest": "", "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" }, + { + "line": 70, + "column": 1, + "endLine": 70, + "endColumn": 10, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 71, + "column": 1, + "endLine": 71, + "endColumn": 10, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 72, "column": 1, @@ -178,7 +198,7 @@ "line": 79, "column": 1, "endLine": 79, - "endColumn": 10, + "endColumn": 11, "problem": "RuntimeArrayCheck", "suggest": "", "rule": "Array bound not checked. (arkts-runtime-array-check)", @@ -188,7 +208,7 @@ "line": 80, "column": 1, "endLine": 80, - "endColumn": 10, + "endColumn": 11, "problem": "RuntimeArrayCheck", "suggest": "", "rule": "Array bound not checked. (arkts-runtime-array-check)", @@ -245,29 +265,9 @@ "severity": "ERROR" }, { - "line": 86, + "line": 97, "column": 1, - "endLine": 86, - "endColumn": 11, - "problem": "RuntimeArrayCheck", - "suggest": "", - "rule": "Array bound not checked. (arkts-runtime-array-check)", - "severity": "ERROR" - }, - { - "line": 87, - "column": 1, - "endLine": 87, - "endColumn": 11, - "problem": "RuntimeArrayCheck", - "suggest": "", - "rule": "Array bound not checked. (arkts-runtime-array-check)", - "severity": "ERROR" - }, - { - "line": 99, - "column": 1, - "endLine": 99, + "endLine": 97, "endColumn": 18, "problem": "UnsupportPropNameFromValue", "suggest": "", @@ -275,9 +275,9 @@ "severity": "ERROR" }, { - "line": 100, + "line": 98, "column": 1, - "endLine": 100, + "endLine": 98, "endColumn": 17, "problem": "UnsupportPropNameFromValue", "suggest": "", @@ -285,9 +285,9 @@ "severity": "ERROR" }, { - "line": 101, + "line": 99, "column": 1, - "endLine": 101, + "endLine": 99, "endColumn": 17, "problem": "UnsupportPropNameFromValue", "suggest": "", @@ -295,9 +295,9 @@ "severity": "ERROR" }, { - "line": 109, + "line": 107, "column": 24, - "endLine": 109, + "endLine": 107, "endColumn": 39, "problem": "ArrayIndexExprType", "suggest": "", @@ -305,9 +305,9 @@ "severity": "ERROR" }, { - "line": 109, + "line": 107, "column": 24, - "endLine": 109, + "endLine": 107, "endColumn": 39, "problem": "BuiltinSymbolIterator", "suggest": "", @@ -315,9 +315,9 @@ "severity": "ERROR" }, { - "line": 110, + "line": 108, "column": 5, - "endLine": 110, + "endLine": 108, "endColumn": 40, "problem": "AnyType", "suggest": "", @@ -325,9 +325,9 @@ "severity": "ERROR" }, { - "line": 119, + "line": 117, "column": 20, - "endLine": 119, + "endLine": 117, "endColumn": 35, "problem": "ArrayIndexExprType", "suggest": "", @@ -335,9 +335,9 @@ "severity": "ERROR" }, { - "line": 119, + "line": 117, "column": 20, - "endLine": 119, + "endLine": 117, "endColumn": 35, "problem": "BuiltinSymbolIterator", "suggest": "", @@ -345,9 +345,9 @@ "severity": "ERROR" }, { - "line": 120, + "line": 118, "column": 5, - "endLine": 120, + "endLine": 118, "endColumn": 36, "problem": "AnyType", "suggest": "", @@ -355,9 +355,9 @@ "severity": "ERROR" }, { - "line": 141, + "line": 139, "column": 12, - "endLine": 141, + "endLine": 139, "endColumn": 31, "problem": "CreatingPrimitiveTypes", "suggest": "", @@ -365,9 +365,9 @@ "severity": "ERROR" }, { - "line": 161, + "line": 159, "column": 3, - "endLine": 161, + "endLine": 159, "endColumn": 9, "problem": "PropertyAccessByIndex", "suggest": "", @@ -375,9 +375,9 @@ "severity": "ERROR" }, { - "line": 174, + "line": 172, "column": 1, - "endLine": 174, + "endLine": 172, "endColumn": 9, "problem": "PropertyAccessByIndex", "suggest": "", @@ -385,9 +385,9 @@ "severity": "ERROR" }, { - "line": 175, + "line": 173, "column": 1, - "endLine": 175, + "endLine": 173, "endColumn": 13, "problem": "PropertyAccessByIndex", "suggest": "", @@ -395,9 +395,9 @@ "severity": "ERROR" }, { - "line": 176, + "line": 174, "column": 1, - "endLine": 176, + "endLine": 174, "endColumn": 13, "problem": "PropertyAccessByIndex", "suggest": "", @@ -405,19 +405,19 @@ "severity": "ERROR" }, { - "line": 183, - "column": 7, - "endLine": 183, - "endColumn": 14, - "problem": "PropertyAccessByIndex", + "line": 181, + "column": 1, + "endLine": 181, + "endColumn": 10, + "problem": "LimitedStdLibNoSendableDecorator", "suggest": "", - "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)", + "rule": "Usage of standard library is restricted(arkts-limited-stdlib-no-sendable-decorator)", "severity": "ERROR" }, { - "line": 194, + "line": 197, "column": 1, - "endLine": 194, + "endLine": 197, "endColumn": 5, "problem": "PropertyAccessByIndex", "suggest": "", @@ -425,9 +425,9 @@ "severity": "ERROR" }, { - "line": 195, + "line": 198, "column": 1, - "endLine": 195, + "endLine": 198, "endColumn": 7, "problem": "PropertyAccessByIndex", "suggest": "", @@ -435,9 +435,9 @@ "severity": "ERROR" }, { - "line": 198, + "line": 201, "column": 1, - "endLine": 198, + "endLine": 201, "endColumn": 23, "problem": "PropertyAccessByIndex", "suggest": "", @@ -445,9 +445,9 @@ "severity": "ERROR" }, { - "line": 210, + "line": 213, "column": 1, - "endLine": 210, + "endLine": 213, "endColumn": 20, "problem": "PropertyAccessByIndex", "suggest": "", @@ -455,4 +455,4 @@ "severity": "ERROR" } ] -} +} \ No newline at end of file