diff --git a/ets2panda/linter/src/lib/TypeScriptLinter.ts b/ets2panda/linter/src/lib/TypeScriptLinter.ts index a15641503fd7aa6af889b0b1b95a5af54dd1809e..b07a1ebe026f4d6e7f36697f5a7fb50a0706ff7b 100644 --- a/ets2panda/linter/src/lib/TypeScriptLinter.ts +++ b/ets2panda/linter/src/lib/TypeScriptLinter.ts @@ -9519,10 +9519,14 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } return false; }; + const isStandardFloatFormat = (): boolean => { + const text = node.getText(); + return /\.\d*0+$/.test(text); + }; const isNoNeedFix = isInElementAccessExpression(node) || - ts.isEnumMember(node.parent) || - 'name' in node.parent && node.parent.name === node; + 'name' in node.parent && node.parent.name === node || + isStandardFloatFormat(); if (isNoNeedFix) { return; } diff --git a/ets2panda/linter/src/lib/autofixes/Autofixer.ts b/ets2panda/linter/src/lib/autofixes/Autofixer.ts index 4ae5c879821774aeb3227d627adc77c4a51a738c..47fc286dabe07a46289931c3c2bc183846447b01 100644 --- a/ets2panda/linter/src/lib/autofixes/Autofixer.ts +++ b/ets2panda/linter/src/lib/autofixes/Autofixer.ts @@ -4851,7 +4851,23 @@ export class Autofixer { fixNumericLiteralIntToNumber(node: ts.NumericLiteral): Autofix[] | undefined { void this; - return [{ start: node.getStart(), end: node.getEnd(), replacementText: `${node.getText()}.0` }]; + let replacementText = node.getText(); + let parent = node.parent; + + if (ts.isPrefixUnaryExpression(parent) && parent.operator === ts.SyntaxKind.MinusToken) { + replacementText = `-${replacementText}.0`; + return [{ + start: parent.getStart(), + end: node.getEnd(), + replacementText + }]; + } + + return [{ + start: node.getStart(), + end: node.getEnd(), + replacementText: `${replacementText}.0` + }]; } fixPropDecorator(node: ts.Decorator, decoratorName: string): Autofix[] { diff --git a/ets2panda/linter/test/main/array_index_expr_type.ets.arkts2.json b/ets2panda/linter/test/main/array_index_expr_type.ets.arkts2.json index 3643204633f2584747bd4fde01082b4531dcfbb4..773b1bcf4951646f3080e7976fae5d7ca475e3b5 100644 --- a/ets2panda/linter/test/main/array_index_expr_type.ets.arkts2.json +++ b/ets2panda/linter/test/main/array_index_expr_type.ets.arkts2.json @@ -754,6 +754,16 @@ "rule": "Enumeration members can be initialized only with compile time expressions of the same type (arkts-no-enum-mixed-types)", "severity": "ERROR" }, + { + "line": 65, + "column": 8, + "endLine": 65, + "endColumn": 9, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { "line": 67, "column": 6, diff --git a/ets2panda/linter/test/main/array_index_expr_type.ets.autofix.json b/ets2panda/linter/test/main/array_index_expr_type.ets.autofix.json index f3c413339478654d0f37c17c2569396314f8e316..395b7396d178188d2220308f792a04c20adcc5f0 100644 --- a/ets2panda/linter/test/main/array_index_expr_type.ets.autofix.json +++ b/ets2panda/linter/test/main/array_index_expr_type.ets.autofix.json @@ -1304,6 +1304,27 @@ "rule": "Enumeration members can be initialized only with compile time expressions of the same type (arkts-no-enum-mixed-types)", "severity": "ERROR" }, + { + "line": 65, + "column": 8, + "endLine": 65, + "endColumn": 9, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1669, + "end": 1670, + "replacementText": "0.0", + "line": 65, + "column": 8, + "endLine": 65, + "endColumn": 9 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { "line": 67, "column": 6, diff --git a/ets2panda/linter/test/main/array_index_expr_type.ets.migrate.ets b/ets2panda/linter/test/main/array_index_expr_type.ets.migrate.ets index 5ba7613e1bb2ecbe420289a8147ba00b8740e6ad..767d9a477fcc6f723540012f08d595754598a149 100644 --- a/ets2panda/linter/test/main/array_index_expr_type.ets.migrate.ets +++ b/ets2panda/linter/test/main/array_index_expr_type.ets.migrate.ets @@ -62,7 +62,7 @@ for (let i: int = 0.0; i < array2.length; i++) { let arr1:number[] = [1.0, 2.0, 3.0] enum TE{ AA = 1.12 - BB = 0 + BB = 0.0 } arr1[TE.AA as int]; arr1[TE.BB]; diff --git a/ets2panda/linter/test/main/enum_not_support_float.ets.arkts2.json b/ets2panda/linter/test/main/enum_not_support_float.ets.arkts2.json index ff258d6c128395ffaa10c3a1f32fcde5e9e2f7cb..95b3bdaefb784e4a83ae9e14da95ab0063b71d7a 100644 --- a/ets2panda/linter/test/main/enum_not_support_float.ets.arkts2.json +++ b/ets2panda/linter/test/main/enum_not_support_float.ets.arkts2.json @@ -14,6 +14,16 @@ "limitations under the License." ], "result": [ + { + "line": 23, + "column": 7, + "endLine": 23, + "endColumn": 9, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { "line": 24, "column": 3, diff --git a/ets2panda/linter/test/main/explicit_function_type.ets.arkts2.json b/ets2panda/linter/test/main/explicit_function_type.ets.arkts2.json index d79abde569bf4dd85df92241a96cba0118cc695a..54fab7a23c30ef326d9e0526f070620f2fe447d4 100755 --- a/ets2panda/linter/test/main/explicit_function_type.ets.arkts2.json +++ b/ets2panda/linter/test/main/explicit_function_type.ets.arkts2.json @@ -224,6 +224,16 @@ "rule": "This keyword cannot be used as identifiers (arkts-invalid-identifier)", "severity": "ERROR" }, + { + "line": 133, + "column": 10, + "endLine": 133, + "endColumn": 11, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { "line": 139, "column": 3, diff --git a/ets2panda/linter/test/main/explicit_function_type.ets.autofix.json b/ets2panda/linter/test/main/explicit_function_type.ets.autofix.json index d3870c4c8f88782bc29409f986e4660d79c7b1d2..e56dd8d5484e363482820e46fa5f99024e6eef9d 100644 --- a/ets2panda/linter/test/main/explicit_function_type.ets.autofix.json +++ b/ets2panda/linter/test/main/explicit_function_type.ets.autofix.json @@ -345,6 +345,27 @@ "rule": "This keyword cannot be used as identifiers (arkts-invalid-identifier)", "severity": "ERROR" }, + { + "line": 133, + "column": 10, + "endLine": 133, + "endColumn": 11, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 2849, + "end": 2850, + "replacementText": "1.0", + "line": 133, + "column": 10, + "endLine": 133, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { "line": 139, "column": 3, diff --git a/ets2panda/linter/test/main/explicit_function_type.ets.migrate.ets b/ets2panda/linter/test/main/explicit_function_type.ets.migrate.ets index 0a5b1a221f4ff54dbded7d2b2c587748901b508a..b5a17d538d7c55338cbb2fa08abfde85fc9c94b6 100644 --- a/ets2panda/linter/test/main/explicit_function_type.ets.migrate.ets +++ b/ets2panda/linter/test/main/explicit_function_type.ets.migrate.ets @@ -130,7 +130,7 @@ let tup38:[['arkts'|Function, 1.0|true, false], string[], Function] = [['arkts', //枚举 enum E39 { Function, - BLUE = 1, + BLUE = 1.0, YELLOW } diff --git a/ets2panda/linter/test/main/exponent.ets.autofix.json b/ets2panda/linter/test/main/exponent.ets.autofix.json index ee4e3b46625385ea9fb4c16f906bf1005963b961..cc6218a973907d838d74561163aeb985f0df4a53 100644 --- a/ets2panda/linter/test/main/exponent.ets.autofix.json +++ b/ets2panda/linter/test/main/exponent.ets.autofix.json @@ -231,9 +231,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 721, + "start": 720, "end": 722, - "replacementText": "1.0", + "replacementText": "-1.0", "line": 25, "column": 15, "endLine": 25, diff --git a/ets2panda/linter/test/main/invalid_identifier.ets.arkts2.json b/ets2panda/linter/test/main/invalid_identifier.ets.arkts2.json index df7367f9debfe680b03a61f933d6da4292479f7d..b1f3898c924c50bf33e08748300aab40a23717fe 100644 --- a/ets2panda/linter/test/main/invalid_identifier.ets.arkts2.json +++ b/ets2panda/linter/test/main/invalid_identifier.ets.arkts2.json @@ -794,6 +794,16 @@ "rule": "This keyword cannot be used as identifiers (arkts-invalid-identifier)", "severity": "ERROR" }, + { + "line": 205, + "column": 12, + "endLine": 205, + "endColumn": 13, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { "line": 206, "column": 3, @@ -804,6 +814,16 @@ "rule": "This keyword cannot be used as identifiers (arkts-invalid-identifier)", "severity": "ERROR" }, + { + "line": 206, + "column": 9, + "endLine": 206, + "endColumn": 10, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { "line": 209, "column": 11, diff --git a/ets2panda/linter/test/main/literals_as_prop_names.ets.arkts2.json b/ets2panda/linter/test/main/literals_as_prop_names.ets.arkts2.json index f6df27e1d6a7c0564173ffaaccdbc53a51ac4bfa..73e1aec0394abac6c2b3f37485c0576edac50f69 100755 --- a/ets2panda/linter/test/main/literals_as_prop_names.ets.arkts2.json +++ b/ets2panda/linter/test/main/literals_as_prop_names.ets.arkts2.json @@ -334,6 +334,16 @@ "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", "severity": "ERROR" }, + { + "line": 92, + "column": 9, + "endLine": 92, + "endColumn": 10, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { "line": 97, "column": 3, @@ -344,6 +354,16 @@ "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", "severity": "ERROR" }, + { + "line": 97, + "column": 10, + "endLine": 97, + "endColumn": 11, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { "line": 98, "column": 3, @@ -354,6 +374,16 @@ "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", "severity": "ERROR" }, + { + "line": 98, + "column": 13, + "endLine": 98, + "endColumn": 14, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { "line": 102, "column": 3, @@ -364,6 +394,16 @@ "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", "severity": "ERROR" }, + { + "line": 102, + "column": 10, + "endLine": 102, + "endColumn": 11, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { "line": 103, "column": 3, @@ -374,6 +414,16 @@ "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", "severity": "ERROR" }, + { + "line": 103, + "column": 13, + "endLine": 103, + "endColumn": 14, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { "line": 105, "column": 5, @@ -424,6 +474,16 @@ "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", "severity": "ERROR" }, + { + "line": 109, + "column": 8, + "endLine": 109, + "endColumn": 9, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { "line": 112, "column": 1, @@ -434,6 +494,16 @@ "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", "severity": "ERROR" }, + { + "line": 112, + "column": 9, + "endLine": 112, + "endColumn": 10, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { "line": 118, "column": 18, diff --git a/ets2panda/linter/test/main/literals_as_prop_names.ets.autofix.json b/ets2panda/linter/test/main/literals_as_prop_names.ets.autofix.json index d66cfd8c7c7ab311afe55cfebf45015d1bcf7369..7cdbaf98955329652803334a9953877599e52bba 100644 --- a/ets2panda/linter/test/main/literals_as_prop_names.ets.autofix.json +++ b/ets2panda/linter/test/main/literals_as_prop_names.ets.autofix.json @@ -738,6 +738,27 @@ "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", "severity": "ERROR" }, + { + "line": 92, + "column": 9, + "endLine": 92, + "endColumn": 10, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1996, + "end": 1997, + "replacementText": "1.0", + "line": 92, + "column": 9, + "endLine": 92, + "endColumn": 10 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { "line": 97, "column": 3, @@ -759,6 +780,27 @@ "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", "severity": "ERROR" }, + { + "line": 97, + "column": 10, + "endLine": 97, + "endColumn": 11, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 2040, + "end": 2041, + "replacementText": "1.0", + "line": 97, + "column": 10, + "endLine": 97, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { "line": 98, "column": 3, @@ -780,6 +822,27 @@ "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", "severity": "ERROR" }, + { + "line": 98, + "column": 13, + "endLine": 98, + "endColumn": 14, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 2055, + "end": 2056, + "replacementText": "1.0", + "line": 98, + "column": 13, + "endLine": 98, + "endColumn": 14 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { "line": 102, "column": 3, @@ -810,6 +873,27 @@ "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", "severity": "ERROR" }, + { + "line": 102, + "column": 10, + "endLine": 102, + "endColumn": 11, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 2095, + "end": 2096, + "replacementText": "1.0", + "line": 102, + "column": 10, + "endLine": 102, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { "line": 103, "column": 3, @@ -840,6 +924,27 @@ "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", "severity": "ERROR" }, + { + "line": 103, + "column": 13, + "endLine": 103, + "endColumn": 14, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 2110, + "end": 2111, + "replacementText": "1.0", + "line": 103, + "column": 13, + "endLine": 103, + "endColumn": 14 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { "line": 105, "column": 5, @@ -932,6 +1037,27 @@ "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", "severity": "ERROR" }, + { + "line": 109, + "column": 8, + "endLine": 109, + "endColumn": 9, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 2214, + "end": 2215, + "replacementText": "1.0", + "line": 109, + "column": 8, + "endLine": 109, + "endColumn": 9 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { "line": 112, "column": 1, @@ -953,6 +1079,27 @@ "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", "severity": "ERROR" }, + { + "line": 112, + "column": 9, + "endLine": 112, + "endColumn": 10, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 2252, + "end": 2253, + "replacementText": "1.0", + "line": 112, + "column": 9, + "endLine": 112, + "endColumn": 10 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { "line": 118, "column": 18, diff --git a/ets2panda/linter/test/main/literals_as_prop_names.ets.migrate.ets b/ets2panda/linter/test/main/literals_as_prop_names.ets.migrate.ets index 5211df075e1f11e4a331d042089183899ccd508d..5c91b9deba7f4e2a7a88f7c676e9d6d1d78d21cf 100644 --- a/ets2panda/linter/test/main/literals_as_prop_names.ets.migrate.ets +++ b/ets2panda/linter/test/main/literals_as_prop_names.ets.migrate.ets @@ -95,27 +95,27 @@ LiteralAsPropertyNameEnum.PrivateTwo; { const enum Direction { - __empty = 1, + __empty = 1.0, } } const enum Direction16 { - ___x5c = 1, - __x5c = 1, + ___x5c = 1.0, + __x5c = 1.0, } const enum Direction17 { - ___x5c = 1, - __x5c = 1, + ___x5c = 1.0, + __x5c = 1.0, } let case17: number = Direction17.___x5c let case172: number = Direction17.__x5c const enum Direction11 { -__x21x21 = 1, +__x21x21 = 1.0, } const enum Direction23 { -aaa = 1, +aaa = 1.0, } // ArkUI @Component diff --git a/ets2panda/linter/test/main/numeric_semantics.ets b/ets2panda/linter/test/main/numeric_semantics.ets index e09d8b47cf7c1fe4bde0f446600b80eaa943059f..ff1a6aece731d3229c75072c5204a7f8df53a80f 100755 --- a/ets2panda/linter/test/main/numeric_semantics.ets +++ b/ets2panda/linter/test/main/numeric_semantics.ets @@ -202,4 +202,26 @@ for (let i:number = 0; i < 100; i++) { } let cancelIds:ArrayList = arr.subArrayList(6, 86) let a: Array = Array.from(cancelIds) -let arr1: Array = Array.from(new ArrayList()) \ No newline at end of file +let arr1: Array = Array.from(new ArrayList()) + +let a:number = 0.000; + +const b:number = 0.000; + +export enum WalletStageValue { + DEFAULT = 0, + SWIPE_INIT = -1, + SELECT_CARD = 1, + SWIPE_DOING = 2, + SWIPE_SUCCEED = 3, + SWIPE_FAILED = 4, + SWIPE_FINISHED = 5, +} + +export enum AnimationStage { + INIT = 0, + ENTER = 1, + ROTATING = 2, + EXIT_START = 3, + EXIT_END = 4, +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/numeric_semantics.ets.arkts2.json b/ets2panda/linter/test/main/numeric_semantics.ets.arkts2.json index d7c46831b14d25e64f496f10c4261b2b9f132733..38ce8825f5ac72086849e6bb8f702e29c337d05b 100755 --- a/ets2panda/linter/test/main/numeric_semantics.ets.arkts2.json +++ b/ets2panda/linter/test/main/numeric_semantics.ets.arkts2.json @@ -514,6 +514,26 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 112, + "column": 7, + "endLine": 112, + "endColumn": 8, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 113, + "column": 7, + "endLine": 113, + "endColumn": 8, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { "line": 115, "column": 7, @@ -1094,6 +1114,126 @@ "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", "severity": "ERROR" }, + { + "line": 212, + "column": 13, + "endLine": 212, + "endColumn": 14, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 213, + "column": 17, + "endLine": 213, + "endColumn": 18, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 214, + "column": 17, + "endLine": 214, + "endColumn": 18, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 215, + "column": 17, + "endLine": 215, + "endColumn": 18, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 216, + "column": 19, + "endLine": 216, + "endColumn": 20, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 217, + "column": 18, + "endLine": 217, + "endColumn": 19, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 218, + "column": 20, + "endLine": 218, + "endColumn": 21, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 222, + "column": 10, + "endLine": 222, + "endColumn": 11, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 223, + "column": 11, + "endLine": 223, + "endColumn": 12, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 224, + "column": 14, + "endLine": 224, + "endColumn": 15, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 225, + "column": 16, + "endLine": 225, + "endColumn": 17, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 226, + "column": 14, + "endLine": 226, + "endColumn": 15, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { "line": 117, "column": 2, diff --git a/ets2panda/linter/test/main/numeric_semantics.ets.autofix.json b/ets2panda/linter/test/main/numeric_semantics.ets.autofix.json index 5045e3f3cb2e3b1e3277ea34162c1b85a723a673..f32b87bf78bfed022cd0cdc95e1d7ca0aa66f318 100644 --- a/ets2panda/linter/test/main/numeric_semantics.ets.autofix.json +++ b/ets2panda/linter/test/main/numeric_semantics.ets.autofix.json @@ -704,9 +704,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2067, + "start": 2066, "end": 2070, - "replacementText": "234.0", + "replacementText": "-234.0", "line": 85, "column": 11, "endLine": 85, @@ -1073,6 +1073,48 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 112, + "column": 7, + "endLine": 112, + "endColumn": 8, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 2446, + "end": 2447, + "replacementText": "1.0", + "line": 112, + "column": 7, + "endLine": 112, + "endColumn": 8 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 113, + "column": 7, + "endLine": 113, + "endColumn": 8, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 2468, + "end": 2469, + "replacementText": "2.0", + "line": 113, + "column": 7, + "endLine": 113, + "endColumn": 8 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { "line": 115, "column": 7, @@ -1636,9 +1678,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 3357, + "start": 3356, "end": 3358, - "replacementText": "1.0", + "replacementText": "-1.0", "line": 149, "column": 17, "endLine": 149, @@ -1657,9 +1699,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 3361, + "start": 3360, "end": 3362, - "replacementText": "1.0", + "replacementText": "-1.0", "line": 149, "column": 21, "endLine": 149, @@ -2170,6 +2212,258 @@ "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", "severity": "ERROR" }, + { + "line": 212, + "column": 13, + "endLine": 212, + "endColumn": 14, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 5206, + "end": 5207, + "replacementText": "0.0", + "line": 212, + "column": 13, + "endLine": 212, + "endColumn": 14 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 213, + "column": 17, + "endLine": 213, + "endColumn": 18, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 5225, + "end": 5227, + "replacementText": "-1.0", + "line": 213, + "column": 17, + "endLine": 213, + "endColumn": 18 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 214, + "column": 17, + "endLine": 214, + "endColumn": 18, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 5246, + "end": 5247, + "replacementText": "1.0", + "line": 214, + "column": 17, + "endLine": 214, + "endColumn": 18 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 215, + "column": 17, + "endLine": 215, + "endColumn": 18, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 5266, + "end": 5267, + "replacementText": "2.0", + "line": 215, + "column": 17, + "endLine": 215, + "endColumn": 18 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 216, + "column": 19, + "endLine": 216, + "endColumn": 20, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 5288, + "end": 5289, + "replacementText": "3.0", + "line": 216, + "column": 19, + "endLine": 216, + "endColumn": 20 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 217, + "column": 18, + "endLine": 217, + "endColumn": 19, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 5309, + "end": 5310, + "replacementText": "4.0", + "line": 217, + "column": 18, + "endLine": 217, + "endColumn": 19 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 218, + "column": 20, + "endLine": 218, + "endColumn": 21, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 5332, + "end": 5333, + "replacementText": "5.0", + "line": 218, + "column": 20, + "endLine": 218, + "endColumn": 21 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 222, + "column": 10, + "endLine": 222, + "endColumn": 11, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 5380, + "end": 5381, + "replacementText": "0.0", + "line": 222, + "column": 10, + "endLine": 222, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 223, + "column": 11, + "endLine": 223, + "endColumn": 12, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 5394, + "end": 5395, + "replacementText": "1.0", + "line": 223, + "column": 11, + "endLine": 223, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 224, + "column": 14, + "endLine": 224, + "endColumn": 15, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 5411, + "end": 5412, + "replacementText": "2.0", + "line": 224, + "column": 14, + "endLine": 224, + "endColumn": 15 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 225, + "column": 16, + "endLine": 225, + "endColumn": 17, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 5430, + "end": 5431, + "replacementText": "3.0", + "line": 225, + "column": 16, + "endLine": 225, + "endColumn": 17 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 226, + "column": 14, + "endLine": 226, + "endColumn": 15, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 5447, + "end": 5448, + "replacementText": "4.0", + "line": 226, + "column": 14, + "endLine": 226, + "endColumn": 15 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { "line": 117, "column": 2, diff --git a/ets2panda/linter/test/main/numeric_semantics.ets.migrate.ets b/ets2panda/linter/test/main/numeric_semantics.ets.migrate.ets index cecf097403e7e26cc5170fc8585ae18efaf67337..ba4df96e9d5d2547d6a0d26396cb8d9769ab96e1 100644 --- a/ets2panda/linter/test/main/numeric_semantics.ets.migrate.ets +++ b/ets2panda/linter/test/main/numeric_semantics.ets.migrate.ets @@ -112,8 +112,8 @@ let g: number = an_array[] const a: number = 1.0 enum Test { - A = 1, // 显式赋值为 1 - B = 2 // 显式赋值为 2 + A = 1.0, // 显式赋值为 1 + B = 2.0 // 显式赋值为 2 } const test: number = Test.A; @@ -208,4 +208,26 @@ for (let i:number = 0.0; i < 100.0; i++) { } let cancelIds:ArrayList = arr.subArrayList(6.0, 86.0) let a: Array = Array.from(cancelIds) -let arr1: Array = Array.from(new ArrayList()) \ No newline at end of file +let arr1: Array = Array.from(new ArrayList()) + +let a:number = 0.000; + +const b:number = 0.000; + +export enum WalletStageValue { + DEFAULT = 0.0, + SWIPE_INIT = -1.0, + SELECT_CARD = 1.0, + SWIPE_DOING = 2.0, + SWIPE_SUCCEED = 3.0, + SWIPE_FAILED = 4.0, + SWIPE_FINISHED = 5.0, +} + +export enum AnimationStage { + INIT = 0.0, + ENTER = 1.0, + ROTATING = 2.0, + EXIT_START = 3.0, + EXIT_END = 4.0, +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/numeric_semantics2.ets.arkts2.json b/ets2panda/linter/test/main/numeric_semantics2.ets.arkts2.json index 6348e6c1b19f3fd7809946819523803ed42024ff..8c2a778ec9f98e3debce809d5fc606ab7aa784bc 100755 --- a/ets2panda/linter/test/main/numeric_semantics2.ets.arkts2.json +++ b/ets2panda/linter/test/main/numeric_semantics2.ets.arkts2.json @@ -224,6 +224,26 @@ "rule": "Array bound not checked. (arkts-runtime-array-check)", "severity": "ERROR" }, + { + "line": 62, + "column": 13, + "endLine": 62, + "endColumn": 14, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 63, + "column": 13, + "endLine": 63, + "endColumn": 14, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { "line": 68, "column": 28, diff --git a/ets2panda/linter/test/main/numeric_semantics2.ets.autofix.json b/ets2panda/linter/test/main/numeric_semantics2.ets.autofix.json index 56b02d155655c37072e96babdff487ef05e5395c..890005064bf088396c63cd5becc06be2048344e5 100644 --- a/ets2panda/linter/test/main/numeric_semantics2.ets.autofix.json +++ b/ets2panda/linter/test/main/numeric_semantics2.ets.autofix.json @@ -439,6 +439,48 @@ "rule": "Array bound not checked. (arkts-runtime-array-check)", "severity": "ERROR" }, + { + "line": 62, + "column": 13, + "endLine": 62, + "endColumn": 14, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1792, + "end": 1793, + "replacementText": "1.0", + "line": 62, + "column": 13, + "endLine": 62, + "endColumn": 14 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 63, + "column": 13, + "endLine": 63, + "endColumn": 14, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1808, + "end": 1809, + "replacementText": "2.0", + "line": 63, + "column": 13, + "endLine": 63, + "endColumn": 14 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { "line": 68, "column": 28, diff --git a/ets2panda/linter/test/main/numeric_semantics2.ets.migrate.ets b/ets2panda/linter/test/main/numeric_semantics2.ets.migrate.ets index db5e2adfbe6a5554f1cd828d4ddf012da092cd75..3b6d90963de29a91d2956a234c216cf8b9eae545 100644 --- a/ets2panda/linter/test/main/numeric_semantics2.ets.migrate.ets +++ b/ets2panda/linter/test/main/numeric_semantics2.ets.migrate.ets @@ -61,8 +61,8 @@ namespace NoNumericSemantics { let h: number = arr[12. as int] enum E { - A = 1, - B = 2 + A = 1.0, + B = 2.0 } } diff --git a/ets2panda/linter/test/main/prop_name_from_value.ets.arkts2.json b/ets2panda/linter/test/main/prop_name_from_value.ets.arkts2.json index 8cd1ddc90823f070036bb9a7f74b3dd407cc64a1..adf8e2459e1312809f9832abff223a0f368f5633 100644 --- a/ets2panda/linter/test/main/prop_name_from_value.ets.arkts2.json +++ b/ets2panda/linter/test/main/prop_name_from_value.ets.arkts2.json @@ -103,6 +103,66 @@ "suggest": "", "rule": "Enum cannot get member name by member value (arkts-unsupport-prop-name-from-value)", "severity": "ERROR" + }, + { + "line": 40, + "column": 27, + "endLine": 40, + "endColumn": 29, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 17, + "endLine": 41, + "endColumn": 18, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 26, + "endLine": 41, + "endColumn": 27, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 35, + "endLine": 41, + "endColumn": 36, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 47, + "column": 7, + "endLine": 47, + "endColumn": 8, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 48, + "column": 7, + "endLine": 48, + "endColumn": 8, + "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/swicth_expr.ets.arkts2.json b/ets2panda/linter/test/main/swicth_expr.ets.arkts2.json index 5ce55a54ac3b3b4b94d6b10bf24348f2a15a4a24..207e0d7ebf74d0b53f12ef7ce8e7538c45e99f3e 100755 --- a/ets2panda/linter/test/main/swicth_expr.ets.arkts2.json +++ b/ets2panda/linter/test/main/swicth_expr.ets.arkts2.json @@ -174,6 +174,26 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 67, + "column": 7, + "endLine": 67, + "endColumn": 8, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 68, + "column": 7, + "endLine": 68, + "endColumn": 8, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { "line": 70, "column": 7,