From 213f790e4795444d2069b64cbb45e15f90596619 Mon Sep 17 00:00:00 2001 From: sniperc96 Date: Wed, 11 Jun 2025 21:01:59 +0800 Subject: [PATCH] Add interface to the whitelist Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICEGJP Signed-off-by: sniperc96 --- .../src/lib/utils/consts/ArkuiImportList.ts | 1 + .../linter/test/main/interface_import_4.ets | 44 ++ .../main/interface_import_4.ets.args.json | 21 + .../main/interface_import_4.ets.arkts2.json | 248 +++++++++ .../main/interface_import_4.ets.autofix.json | 490 ++++++++++++++++++ .../test/main/interface_import_4.ets.json | 17 + .../main/interface_import_4.ets.migrate.ets | 46 ++ .../main/interface_import_4.ets.migrate.json | 28 + 8 files changed, 895 insertions(+) create mode 100644 ets2panda/linter/test/main/interface_import_4.ets create mode 100644 ets2panda/linter/test/main/interface_import_4.ets.args.json create mode 100644 ets2panda/linter/test/main/interface_import_4.ets.arkts2.json create mode 100644 ets2panda/linter/test/main/interface_import_4.ets.autofix.json create mode 100644 ets2panda/linter/test/main/interface_import_4.ets.json create mode 100644 ets2panda/linter/test/main/interface_import_4.ets.migrate.ets create mode 100644 ets2panda/linter/test/main/interface_import_4.ets.migrate.json diff --git a/ets2panda/linter/src/lib/utils/consts/ArkuiImportList.ts b/ets2panda/linter/src/lib/utils/consts/ArkuiImportList.ts index 9ae6e8d95e..a96ca60dd8 100644 --- a/ets2panda/linter/src/lib/utils/consts/ArkuiImportList.ts +++ b/ets2panda/linter/src/lib/utils/consts/ArkuiImportList.ts @@ -1102,6 +1102,7 @@ export const arkuiImportList: Set = new Set([ 'RenderProcessNotRespondingData', 'RenderProcessNotRespondingReason', 'RenderingContextSettings', + 'Repeat', 'RepeatAttribute', 'RepeatItem', 'RepeatMode', diff --git a/ets2panda/linter/test/main/interface_import_4.ets b/ets2panda/linter/test/main/interface_import_4.ets new file mode 100644 index 0000000000..f682328f82 --- /dev/null +++ b/ets2panda/linter/test/main/interface_import_4.ets @@ -0,0 +1,44 @@ +/* + * 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. + */ + +@Entry +@ComponentV2 +struct MyComponent { + @Local arr: Array = []; + scroller: Scroller = new Scroller(); + build() { + Column({ space: 5 }) { + List({ scroller: this.scroller, space: 5, initialIndex: 100 }) { + Repeat(this.arr) + .virtualScroll({ + onTotalCount: () => { return 1000; }, + onLazyLoading: (index: number) => { this.arr[index] = index.toString(); } + }) + .each((obj: RepeatItem) => { + ListItem() { + Row({ space: 5 }) { + Text(`${obj.index}: Item_${obj.item}`) + } + } + .height(50) + }) + } + .height('80%') + .border({ width: 1}) + Button('ScrollToIndex 500') + .onClick(() => { this.scroller.scrollToIndex(500); }) + } + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/interface_import_4.ets.args.json b/ets2panda/linter/test/main/interface_import_4.ets.args.json new file mode 100644 index 0000000000..ef3938e967 --- /dev/null +++ b/ets2panda/linter/test/main/interface_import_4.ets.args.json @@ -0,0 +1,21 @@ +{ + "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." + ], + "mode": { + "arkts2": "", + "autofix": "--arkts-2", + "migrate": "--arkts-2" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/interface_import_4.ets.arkts2.json b/ets2panda/linter/test/main/interface_import_4.ets.arkts2.json new file mode 100644 index 0000000000..420413bad9 --- /dev/null +++ b/ets2panda/linter/test/main/interface_import_4.ets.arkts2.json @@ -0,0 +1,248 @@ +{ + "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": 20, + "column": 28, + "endLine": 20, + "endColumn": 36, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 21, + "endLine": 22, + "endColumn": 22, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 46, + "endLine": 23, + "endColumn": 47, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 63, + "endLine": 23, + "endColumn": 66, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 42, + "endLine": 26, + "endColumn": 46, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 58, + "endLine": 27, + "endColumn": 63, + "problem": "ArrayIndexExprType", + "suggest": "", + "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 28, + "endLine": 31, + "endColumn": 29, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 21, + "endLine": 35, + "endColumn": 23, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 39, + "column": 24, + "endLine": 39, + "endColumn": 25, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 54, + "endLine": 41, + "endColumn": 57, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 16, + "column": 2, + "endLine": 16, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 2, + "endLine": 17, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 4, + "endLine": 19, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 13, + "endLine": 20, + "endColumn": 21, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 28, + "endLine": 20, + "endColumn": 36, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 5, + "endLine": 22, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 7, + "endLine": 23, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 9, + "endLine": 24, + "endColumn": 15, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 23, + "endLine": 29, + "endColumn": 33, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 13, + "endLine": 30, + "endColumn": 21, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 15, + "endLine": 31, + "endColumn": 18, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 17, + "endLine": 32, + "endColumn": 21, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 7, + "endLine": 40, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/interface_import_4.ets.autofix.json b/ets2panda/linter/test/main/interface_import_4.ets.autofix.json new file mode 100644 index 0000000000..8596489ebc --- /dev/null +++ b/ets2panda/linter/test/main/interface_import_4.ets.autofix.json @@ -0,0 +1,490 @@ +{ + "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": 20, + "column": 28, + "endLine": 20, + "endColumn": 36, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 21, + "endLine": 22, + "endColumn": 22, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 751, + "end": 752, + "replacementText": "5.0", + "line": 22, + "column": 21, + "endLine": 22, + "endColumn": 22 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 46, + "endLine": 23, + "endColumn": 47, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 803, + "end": 804, + "replacementText": "5.0", + "line": 23, + "column": 46, + "endLine": 23, + "endColumn": 47 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 63, + "endLine": 23, + "endColumn": 66, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 820, + "end": 823, + "replacementText": "100.0", + "line": 23, + "column": 63, + "endLine": 23, + "endColumn": 66 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 42, + "endLine": 26, + "endColumn": 46, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 922, + "end": 926, + "replacementText": "1000.0", + "line": 26, + "column": 42, + "endLine": 26, + "endColumn": 46 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 58, + "endLine": 27, + "endColumn": 63, + "problem": "ArrayIndexExprType", + "autofix": [ + { + "start": 988, + "end": 993, + "replacementText": "index as int", + "line": 27, + "column": 58, + "endLine": 27, + "endColumn": 63 + } + ], + "suggest": "", + "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 28, + "endLine": 31, + "endColumn": 29, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1129, + "end": 1130, + "replacementText": "5.0", + "line": 31, + "column": 28, + "endLine": 31, + "endColumn": 29 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 21, + "endLine": 35, + "endColumn": 23, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1241, + "end": 1243, + "replacementText": "50.0", + "line": 35, + "column": 21, + "endLine": 35, + "endColumn": 23 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 39, + "column": 24, + "endLine": 39, + "endColumn": 25, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1310, + "end": 1311, + "replacementText": "1.0", + "line": 39, + "column": 24, + "endLine": 39, + "endColumn": 25 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 54, + "endLine": 41, + "endColumn": 57, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1401, + "end": 1404, + "replacementText": "500.0", + "line": 41, + "column": 54, + "endLine": 41, + "endColumn": 57 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 16, + "column": 2, + "endLine": 16, + "endColumn": 7, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, ComponentV2, Local, Scroller, Column, List, Repeat, RepeatItem, ListItem, Row, Text, Button } from '@kit.ArkUI';", + "line": 40, + "column": 7, + "endLine": 40, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 2, + "endLine": 17, + "endColumn": 13, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, ComponentV2, Local, Scroller, Column, List, Repeat, RepeatItem, ListItem, Row, Text, Button } from '@kit.ArkUI';", + "line": 40, + "column": 7, + "endLine": 40, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 4, + "endLine": 19, + "endColumn": 9, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, ComponentV2, Local, Scroller, Column, List, Repeat, RepeatItem, ListItem, Row, Text, Button } from '@kit.ArkUI';", + "line": 40, + "column": 7, + "endLine": 40, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 13, + "endLine": 20, + "endColumn": 21, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, ComponentV2, Local, Scroller, Column, List, Repeat, RepeatItem, ListItem, Row, Text, Button } from '@kit.ArkUI';", + "line": 40, + "column": 7, + "endLine": 40, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 28, + "endLine": 20, + "endColumn": 36, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, ComponentV2, Local, Scroller, Column, List, Repeat, RepeatItem, ListItem, Row, Text, Button } from '@kit.ArkUI';", + "line": 40, + "column": 7, + "endLine": 40, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 5, + "endLine": 22, + "endColumn": 11, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, ComponentV2, Local, Scroller, Column, List, Repeat, RepeatItem, ListItem, Row, Text, Button } from '@kit.ArkUI';", + "line": 40, + "column": 7, + "endLine": 40, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 7, + "endLine": 23, + "endColumn": 11, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, ComponentV2, Local, Scroller, Column, List, Repeat, RepeatItem, ListItem, Row, Text, Button } from '@kit.ArkUI';", + "line": 40, + "column": 7, + "endLine": 40, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 9, + "endLine": 24, + "endColumn": 15, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, ComponentV2, Local, Scroller, Column, List, Repeat, RepeatItem, ListItem, Row, Text, Button } from '@kit.ArkUI';", + "line": 40, + "column": 7, + "endLine": 40, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 23, + "endLine": 29, + "endColumn": 33, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, ComponentV2, Local, Scroller, Column, List, Repeat, RepeatItem, ListItem, Row, Text, Button } from '@kit.ArkUI';", + "line": 40, + "column": 7, + "endLine": 40, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 13, + "endLine": 30, + "endColumn": 21, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, ComponentV2, Local, Scroller, Column, List, Repeat, RepeatItem, ListItem, Row, Text, Button } from '@kit.ArkUI';", + "line": 40, + "column": 7, + "endLine": 40, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 15, + "endLine": 31, + "endColumn": 18, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, ComponentV2, Local, Scroller, Column, List, Repeat, RepeatItem, ListItem, Row, Text, Button } from '@kit.ArkUI';", + "line": 40, + "column": 7, + "endLine": 40, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 17, + "endLine": 32, + "endColumn": 21, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, ComponentV2, Local, Scroller, Column, List, Repeat, RepeatItem, ListItem, Row, Text, Button } from '@kit.ArkUI';", + "line": 40, + "column": 7, + "endLine": 40, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 7, + "endLine": 40, + "endColumn": 13, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, ComponentV2, Local, Scroller, Column, List, Repeat, RepeatItem, ListItem, Row, Text, Button } from '@kit.ArkUI';", + "line": 40, + "column": 7, + "endLine": 40, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/interface_import_4.ets.json b/ets2panda/linter/test/main/interface_import_4.ets.json new file mode 100644 index 0000000000..ca88f857e9 --- /dev/null +++ b/ets2panda/linter/test/main/interface_import_4.ets.json @@ -0,0 +1,17 @@ +{ + "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": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/interface_import_4.ets.migrate.ets b/ets2panda/linter/test/main/interface_import_4.ets.migrate.ets new file mode 100644 index 0000000000..0087934e5c --- /dev/null +++ b/ets2panda/linter/test/main/interface_import_4.ets.migrate.ets @@ -0,0 +1,46 @@ +/* + * 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. + */ + +import { Entry, ComponentV2, Local, Scroller, Column, List, Repeat, RepeatItem, ListItem, Row, Text, Button } from '@kit.ArkUI'; + +@Entry +@ComponentV2 +struct MyComponent { + @Local arr: Array = []; + scroller: Scroller = new Scroller(); + build() { + Column({ space: 5.0 }) { + List({ scroller: this.scroller, space: 5.0, initialIndex: 100.0 }) { + Repeat(this.arr) + .virtualScroll({ + onTotalCount: () => { return 1000.0; }, + onLazyLoading: (index: number) => { this.arr[index as int] = index.toString(); } + }) + .each((obj: RepeatItem) => { + ListItem() { + Row({ space: 5.0 }) { + Text(`${obj.index}: Item_${obj.item}`) + } + } + .height(50.0) + }) + } + .height('80%') + .border({ width: 1.0}) + Button('ScrollToIndex 500') + .onClick(() => { this.scroller.scrollToIndex(500.0); }) + } + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/interface_import_4.ets.migrate.json b/ets2panda/linter/test/main/interface_import_4.ets.migrate.json new file mode 100644 index 0000000000..1aecbf6f53 --- /dev/null +++ b/ets2panda/linter/test/main/interface_import_4.ets.migrate.json @@ -0,0 +1,28 @@ +{ + "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": 22, + "column": 28, + "endLine": 22, + "endColumn": 36, + "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 -- Gitee