diff --git a/ets2panda/linter/src/lib/CookBookMsg.ts b/ets2panda/linter/src/lib/CookBookMsg.ts index 146930912e221b2a5399c4fb669c9d2822bff217..17c0d8899bd90376a4622929ddf11a9814eef842 100644 --- a/ets2panda/linter/src/lib/CookBookMsg.ts +++ b/ets2panda/linter/src/lib/CookBookMsg.ts @@ -280,7 +280,7 @@ cookBookTag[270] = 'ArkTS1.2 cannot catch a non Error instance thrown from JS co cookBookTag[274] = 'The subclass constructor must call the parent class\'s parametered constructor (arkts-subclass-must-call-super-constructor-with-args)'; cookBookTag[275] = - 'Custom components with custom layout capability need to add the "@Layoutable" decorator (arkui-custom-layout-need-add-decorator)'; + 'Custom components with custom layout capability need to add the "@CustomLayout" decorator (arkui-custom-layout-need-add-decorator)'; cookBookTag[281] = '"@Prop" decorator is not supported (arkui-no-prop-decorator)'; cookBookTag[282] = '"@StorageProp" decorator is not supported (arkui-no-storageprop-decorator)'; cookBookTag[283] = '"@LocalStorageProp" decorator is not supported (arkui-no-localstorageprop-decorator)'; diff --git a/ets2panda/linter/src/lib/TypeScriptLinter.ts b/ets2panda/linter/src/lib/TypeScriptLinter.ts index 4b72c290e05d73733982df18ff0bd274c0acbbdd..e78caeeb3224403d4d6b50e1bf62fc38b285ee46 100644 --- a/ets2panda/linter/src/lib/TypeScriptLinter.ts +++ b/ets2panda/linter/src/lib/TypeScriptLinter.ts @@ -9617,7 +9617,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { if (decorators) { for (const decorator of decorators) { const decoratorName = TsUtils.getDecoratorName(decorator); - if (decoratorName && decoratorName === CustomDecoratorName.Layoutable) { + if (decoratorName && decoratorName === CustomDecoratorName.CustomLayout) { return; } } diff --git a/ets2panda/linter/src/lib/autofixes/Autofixer.ts b/ets2panda/linter/src/lib/autofixes/Autofixer.ts index 1a85f9c1b535134a04c8f44ac101f6af45ae36e2..201753ae3785eb094550ba5fcf55ea77d92f6085 100644 --- a/ets2panda/linter/src/lib/autofixes/Autofixer.ts +++ b/ets2panda/linter/src/lib/autofixes/Autofixer.ts @@ -4967,7 +4967,7 @@ export class Autofixer { fixCustomLayout(node: ts.StructDeclaration): Autofix[] { const startPos = Autofixer.getStartPositionWithoutDecorators(node); - const decorator = ts.factory.createDecorator(ts.factory.createIdentifier(CustomDecoratorName.Layoutable)); + const decorator = ts.factory.createDecorator(ts.factory.createIdentifier(CustomDecoratorName.CustomLayout)); const text = this.getNewLine() + this.printer.printNode(ts.EmitHint.Unspecified, decorator, node.getSourceFile()); return [{ start: startPos, end: startPos, replacementText: text }]; diff --git a/ets2panda/linter/src/lib/utils/consts/ArkuiConstants.ts b/ets2panda/linter/src/lib/utils/consts/ArkuiConstants.ts index 369c37a8353fc5b322be48be53846a370c604995..b12761975d76cbc0d90ea7086ecb24888d1e84e2 100644 --- a/ets2panda/linter/src/lib/utils/consts/ArkuiConstants.ts +++ b/ets2panda/linter/src/lib/utils/consts/ArkuiConstants.ts @@ -34,7 +34,7 @@ export enum CustomDecoratorName { AnimatableExtend = 'AnimatableExtend', Memo = 'Memo', Observed = 'Observed', - Layoutable = 'Layoutable' + CustomLayout = 'CustomLayout' } export enum StorageTypeName { diff --git a/ets2panda/linter/src/lib/utils/consts/ArkuiImportList.ts b/ets2panda/linter/src/lib/utils/consts/ArkuiImportList.ts index a96ca60dd8fe21b551ffec9ba2d2adebb275305e..3adcc10ab53b75ec891144762a4ee0863c043e63 100644 --- a/ets2panda/linter/src/lib/utils/consts/ArkuiImportList.ts +++ b/ets2panda/linter/src/lib/utils/consts/ArkuiImportList.ts @@ -262,6 +262,7 @@ export const arkuiImportList: Set = new Set([ 'CrownSensitivity', 'CurrentDayStyle', 'Curve', + 'CustomLayout', 'CustomBuilder', 'CustomComponent', 'CustomComponentV2', diff --git a/ets2panda/linter/test/main/custom_layout.ets b/ets2panda/linter/test/main/custom_layout.ets index 233a5aaa79d649a1bb3495a25e6cac4ec5b782e9..eb0c300ec863379315cc824d1a5f91875ea6115d 100644 --- a/ets2panda/linter/test/main/custom_layout.ets +++ b/ets2panda/linter/test/main/custom_layout.ets @@ -20,6 +20,7 @@ struct Index { Column() { CustomLayout1({ builder: ColumnChildren }) CustomLayout2({ builder: ColumnChildren }) + CustomLayout3({ builder: ColumnChildren }) } } } @@ -94,7 +95,44 @@ struct CustomLayout2 { @Component struct CustomLayout3 { - build { + @Builder + doNothingBuilder() { + }; + + @BuilderParam builder: () => void = this.doNothingBuilder; + @State startSize: number = 100; + result: SizeResult = { + width: 0, + height: 0 + }; + + onMeasureSize(selfLayoutInfo: GeometryInfo, children: Array, constraint: ConstraintSizeOptions) { + let size = 100; + children.forEach((child) => { + let result: MeasureResult = child.measure({ minHeight: size, minWidth: size, maxWidth: size, maxHeight: size }) + size += result.width / 2; + }) + this.result.width = 100; + this.result.height = 400; + return this.result; + } + + onPlaceChildren(selfLayoutInfo: GeometryInfo, children: Array, constraint: ConstraintSizeOptions) { + let startPos = 300; + children.forEach((child) => { + let pos = startPos - child.measureResult.height; + child.layout({ x: pos, y: pos }) + }) + } + + build() { + this.builder() + } +} + +@Component +struct CustomLayout4 { + build() { } } \ No newline at end of file diff --git a/ets2panda/linter/test/main/custom_layout.ets.arkts2.json b/ets2panda/linter/test/main/custom_layout.ets.arkts2.json index c19c4c5ff09ec125155a850474aa6b1eceafeadc..afc0270a6457ad39dcf01aa5d50e4eda3d3181f4 100644 --- a/ets2panda/linter/test/main/custom_layout.ets.arkts2.json +++ b/ets2panda/linter/test/main/custom_layout.ets.arkts2.json @@ -15,9 +15,9 @@ ], "result": [ { - "line": 29, + "line": 30, "column": 12, - "endLine": 29, + "endLine": 30, "endColumn": 13, "problem": "NumericSemantics", "suggest": "", @@ -25,9 +25,9 @@ "severity": "ERROR" }, { - "line": 29, + "line": 30, "column": 15, - "endLine": 29, + "endLine": 30, "endColumn": 16, "problem": "NumericSemantics", "suggest": "", @@ -35,9 +35,9 @@ "severity": "ERROR" }, { - "line": 29, + "line": 30, "column": 18, - "endLine": 29, + "endLine": 30, "endColumn": 19, "problem": "NumericSemantics", "suggest": "", @@ -45,9 +45,9 @@ "severity": "ERROR" }, { - "line": 31, + "line": 32, "column": 17, - "endLine": 31, + "endLine": 32, "endColumn": 19, "problem": "NumericSemantics", "suggest": "", @@ -55,9 +55,9 @@ "severity": "ERROR" }, { - "line": 32, + "line": 33, "column": 14, - "endLine": 32, + "endLine": 33, "endColumn": 17, "problem": "NumericSemantics", "suggest": "", @@ -65,9 +65,9 @@ "severity": "ERROR" }, { - "line": 33, + "line": 34, "column": 15, - "endLine": 33, + "endLine": 34, "endColumn": 18, "problem": "NumericSemantics", "suggest": "", @@ -75,9 +75,9 @@ "severity": "ERROR" }, { - "line": 34, + "line": 35, "column": 20, - "endLine": 34, + "endLine": 35, "endColumn": 21, "problem": "NumericSemantics", "suggest": "", @@ -85,9 +85,9 @@ "severity": "ERROR" }, { - "line": 35, + "line": 36, "column": 20, - "endLine": 35, + "endLine": 36, "endColumn": 22, "problem": "NumericSemantics", "suggest": "", @@ -95,9 +95,9 @@ "severity": "ERROR" }, { - "line": 35, + "line": 36, "column": 27, - "endLine": 35, + "endLine": 36, "endColumn": 29, "problem": "NumericSemantics", "suggest": "", @@ -105,19 +105,19 @@ "severity": "ERROR" }, { - "line": 40, + "line": 41, "column": 8, - "endLine": 40, + "endLine": 41, "endColumn": 21, "problem": "CustomLayoutNeedAddDecorator", "suggest": "", - "rule": "Custom components with custom layout capability need to add the \"@Layoutable\" decorator (arkui-custom-layout-need-add-decorator)", + "rule": "Custom components with custom layout capability need to add the \"@CustomLayout\" decorator (arkui-custom-layout-need-add-decorator)", "severity": "ERROR" }, { - "line": 46, + "line": 47, "column": 30, - "endLine": 46, + "endLine": 47, "endColumn": 33, "problem": "NumericSemantics", "suggest": "", @@ -125,9 +125,9 @@ "severity": "ERROR" }, { - "line": 48, + "line": 49, "column": 12, - "endLine": 48, + "endLine": 49, "endColumn": 13, "problem": "NumericSemantics", "suggest": "", @@ -135,9 +135,9 @@ "severity": "ERROR" }, { - "line": 49, + "line": 50, "column": 13, - "endLine": 49, + "endLine": 50, "endColumn": 14, "problem": "NumericSemantics", "suggest": "", @@ -145,9 +145,9 @@ "severity": "ERROR" }, { - "line": 53, + "line": 54, "column": 9, - "endLine": 53, + "endLine": 54, "endColumn": 23, "problem": "NumericSemantics", "suggest": "", @@ -155,9 +155,9 @@ "severity": "ERROR" }, { - "line": 53, + "line": 54, "column": 20, - "endLine": 53, + "endLine": 54, "endColumn": 23, "problem": "NumericSemantics", "suggest": "", @@ -165,9 +165,9 @@ "severity": "ERROR" }, { - "line": 55, + "line": 56, "column": 11, - "endLine": 55, + "endLine": 56, "endColumn": 54, "problem": "NumericSemantics", "suggest": "", @@ -175,19 +175,19 @@ "severity": "ERROR" }, { - "line": 66, + "line": 67, "column": 8, - "endLine": 66, + "endLine": 67, "endColumn": 21, "problem": "CustomLayoutNeedAddDecorator", "suggest": "", - "rule": "Custom components with custom layout capability need to add the \"@Layoutable\" decorator (arkui-custom-layout-need-add-decorator)", + "rule": "Custom components with custom layout capability need to add the \"@CustomLayout\" decorator (arkui-custom-layout-need-add-decorator)", "severity": "ERROR" }, { - "line": 72, + "line": 73, "column": 30, - "endLine": 72, + "endLine": 73, "endColumn": 33, "problem": "NumericSemantics", "suggest": "", @@ -195,9 +195,9 @@ "severity": "ERROR" }, { - "line": 74, + "line": 75, "column": 12, - "endLine": 74, + "endLine": 75, "endColumn": 13, "problem": "NumericSemantics", "suggest": "", @@ -205,9 +205,9 @@ "severity": "ERROR" }, { - "line": 75, + "line": 76, "column": 13, - "endLine": 75, + "endLine": 76, "endColumn": 14, "problem": "NumericSemantics", "suggest": "", @@ -215,9 +215,9 @@ "severity": "ERROR" }, { - "line": 79, + "line": 80, "column": 9, - "endLine": 79, + "endLine": 80, "endColumn": 19, "problem": "NumericSemantics", "suggest": "", @@ -225,9 +225,9 @@ "severity": "ERROR" }, { - "line": 79, + "line": 80, "column": 16, - "endLine": 79, + "endLine": 80, "endColumn": 19, "problem": "NumericSemantics", "suggest": "", @@ -235,9 +235,9 @@ "severity": "ERROR" }, { - "line": 82, + "line": 83, "column": 30, - "endLine": 82, + "endLine": 83, "endColumn": 31, "problem": "NumericSemantics", "suggest": "", @@ -245,9 +245,9 @@ "severity": "ERROR" }, { - "line": 85, + "line": 86, "column": 25, - "endLine": 85, + "endLine": 86, "endColumn": 28, "problem": "NumericSemantics", "suggest": "", @@ -255,9 +255,9 @@ "severity": "ERROR" }, { - "line": 86, + "line": 87, "column": 26, - "endLine": 86, + "endLine": 87, "endColumn": 29, "problem": "NumericSemantics", "suggest": "", @@ -266,12 +266,122 @@ }, { "line": 97, - "column": 3, + "column": 8, "endLine": 97, - "endColumn": 8, - "problem": "AnyType", + "endColumn": 21, + "problem": "CustomLayoutNeedAddDecorator", + "suggest": "", + "rule": "Custom components with custom layout capability need to add the \"@CustomLayout\" decorator (arkui-custom-layout-need-add-decorator)", + "severity": "ERROR" + }, + { + "line": 103, + "column": 30, + "endLine": 103, + "endColumn": 33, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 105, + "column": 12, + "endLine": 105, + "endColumn": 13, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 106, + "column": 13, + "endLine": 106, + "endColumn": 14, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 110, + "column": 9, + "endLine": 110, + "endColumn": 19, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 110, + "column": 16, + "endLine": 110, + "endColumn": 19, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 113, + "column": 30, + "endLine": 113, + "endColumn": 31, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 115, + "column": 25, + "endLine": 115, + "endColumn": 28, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 116, + "column": 26, + "endLine": 116, + "endColumn": 29, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 121, + "column": 9, + "endLine": 121, + "endColumn": 23, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 121, + "column": 20, + "endLine": 121, + "endColumn": 23, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 123, + "column": 11, + "endLine": 123, + "endColumn": 54, + "problem": "NumericSemantics", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, { @@ -305,9 +415,9 @@ "severity": "ERROR" }, { - "line": 27, + "line": 28, "column": 2, - "endLine": 27, + "endLine": 28, "endColumn": 9, "problem": "UIInterfaceImport", "suggest": "", @@ -315,9 +425,9 @@ "severity": "ERROR" }, { - "line": 29, + "line": 30, "column": 3, - "endLine": 29, + "endLine": 30, "endColumn": 10, "problem": "UIInterfaceImport", "suggest": "", @@ -325,9 +435,9 @@ "severity": "ERROR" }, { - "line": 30, + "line": 31, "column": 5, - "endLine": 30, + "endLine": 31, "endColumn": 9, "problem": "UIInterfaceImport", "suggest": "", @@ -335,9 +445,9 @@ "severity": "ERROR" }, { - "line": 39, + "line": 40, "column": 2, - "endLine": 39, + "endLine": 40, "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", @@ -345,9 +455,9 @@ "severity": "ERROR" }, { - "line": 41, + "line": 42, "column": 4, - "endLine": 41, + "endLine": 42, "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", @@ -355,9 +465,9 @@ "severity": "ERROR" }, { - "line": 45, + "line": 46, "column": 4, - "endLine": 45, + "endLine": 46, "endColumn": 16, "problem": "UIInterfaceImport", "suggest": "", @@ -365,9 +475,9 @@ "severity": "ERROR" }, { - "line": 46, + "line": 47, "column": 4, - "endLine": 46, + "endLine": 47, "endColumn": 9, "problem": "UIInterfaceImport", "suggest": "", @@ -375,9 +485,9 @@ "severity": "ERROR" }, { - "line": 47, + "line": 48, "column": 11, - "endLine": 47, + "endLine": 48, "endColumn": 21, "problem": "UIInterfaceImport", "suggest": "", @@ -385,9 +495,9 @@ "severity": "ERROR" }, { - "line": 52, + "line": 53, "column": 35, - "endLine": 52, + "endLine": 53, "endColumn": 47, "problem": "UIInterfaceImport", "suggest": "", @@ -395,9 +505,9 @@ "severity": "ERROR" }, { - "line": 52, + "line": 53, "column": 65, - "endLine": 52, + "endLine": 53, "endColumn": 75, "problem": "UIInterfaceImport", "suggest": "", @@ -405,9 +515,9 @@ "severity": "ERROR" }, { - "line": 52, + "line": 53, "column": 90, - "endLine": 52, + "endLine": 53, "endColumn": 111, "problem": "UIInterfaceImport", "suggest": "", @@ -415,9 +525,9 @@ "severity": "ERROR" }, { - "line": 65, + "line": 66, "column": 2, - "endLine": 65, + "endLine": 66, "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", @@ -425,9 +535,9 @@ "severity": "ERROR" }, { - "line": 67, + "line": 68, "column": 4, - "endLine": 67, + "endLine": 68, "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", @@ -435,9 +545,9 @@ "severity": "ERROR" }, { - "line": 71, + "line": 72, "column": 4, - "endLine": 71, + "endLine": 72, "endColumn": 16, "problem": "UIInterfaceImport", "suggest": "", @@ -445,9 +555,9 @@ "severity": "ERROR" }, { - "line": 72, + "line": 73, "column": 4, - "endLine": 72, + "endLine": 73, "endColumn": 9, "problem": "UIInterfaceImport", "suggest": "", @@ -455,9 +565,99 @@ "severity": "ERROR" }, { - "line": 73, + "line": 74, "column": 11, - "endLine": 73, + "endLine": 74, + "endColumn": 21, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"SizeResult\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 79, + "column": 33, + "endLine": 79, + "endColumn": 45, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"GeometryInfo\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 79, + "column": 63, + "endLine": 79, + "endColumn": 73, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Measurable\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 79, + "column": 88, + "endLine": 79, + "endColumn": 109, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ConstraintSizeOptions\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 82, + "column": 19, + "endLine": 82, + "endColumn": 32, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"MeasureResult\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 96, + "column": 2, + "endLine": 96, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 98, + "column": 4, + "endLine": 98, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Builder\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 102, + "column": 4, + "endLine": 102, + "endColumn": 16, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"BuilderParam\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 103, + "column": 4, + "endLine": 103, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 104, + "column": 11, + "endLine": 104, "endColumn": 21, "problem": "UIInterfaceImport", "suggest": "", @@ -465,9 +665,9 @@ "severity": "ERROR" }, { - "line": 78, + "line": 109, "column": 33, - "endLine": 78, + "endLine": 109, "endColumn": 45, "problem": "UIInterfaceImport", "suggest": "", @@ -475,9 +675,9 @@ "severity": "ERROR" }, { - "line": 78, + "line": 109, "column": 63, - "endLine": 78, + "endLine": 109, "endColumn": 73, "problem": "UIInterfaceImport", "suggest": "", @@ -485,9 +685,9 @@ "severity": "ERROR" }, { - "line": 78, + "line": 109, "column": 88, - "endLine": 78, + "endLine": 109, "endColumn": 109, "problem": "UIInterfaceImport", "suggest": "", @@ -495,9 +695,9 @@ "severity": "ERROR" }, { - "line": 81, + "line": 112, "column": 19, - "endLine": 81, + "endLine": 112, "endColumn": 32, "problem": "UIInterfaceImport", "suggest": "", @@ -505,9 +705,39 @@ "severity": "ERROR" }, { - "line": 95, + "line": 120, + "column": 35, + "endLine": 120, + "endColumn": 47, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"GeometryInfo\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 120, + "column": 65, + "endLine": 120, + "endColumn": 75, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Layoutable\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 120, + "column": 90, + "endLine": 120, + "endColumn": 111, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ConstraintSizeOptions\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 133, "column": 2, - "endLine": 95, + "endLine": 133, "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", diff --git a/ets2panda/linter/test/main/custom_layout.ets.autofix.json b/ets2panda/linter/test/main/custom_layout.ets.autofix.json index 02685c24c8858f64f608c4b321857018adb5e454..ac5f81be97742e9dc8641a81d0578c5f753e5a6a 100644 --- a/ets2panda/linter/test/main/custom_layout.ets.autofix.json +++ b/ets2panda/linter/test/main/custom_layout.ets.autofix.json @@ -15,19 +15,19 @@ ], "result": [ { - "line": 29, + "line": 30, "column": 12, - "endLine": 29, + "endLine": 30, "endColumn": 13, "problem": "NumericSemantics", "autofix": [ { - "start": 824, - "end": 825, + "start": 873, + "end": 874, "replacementText": "1.0", - "line": 29, + "line": 30, "column": 12, - "endLine": 29, + "endLine": 30, "endColumn": 13 } ], @@ -36,19 +36,19 @@ "severity": "ERROR" }, { - "line": 29, + "line": 30, "column": 15, - "endLine": 29, + "endLine": 30, "endColumn": 16, "problem": "NumericSemantics", "autofix": [ { - "start": 827, - "end": 828, + "start": 876, + "end": 877, "replacementText": "2.0", - "line": 29, + "line": 30, "column": 15, - "endLine": 29, + "endLine": 30, "endColumn": 16 } ], @@ -57,19 +57,19 @@ "severity": "ERROR" }, { - "line": 29, + "line": 30, "column": 18, - "endLine": 29, + "endLine": 30, "endColumn": 19, "problem": "NumericSemantics", "autofix": [ { - "start": 830, - "end": 831, + "start": 879, + "end": 880, "replacementText": "3.0", - "line": 29, + "line": 30, "column": 18, - "endLine": 29, + "endLine": 30, "endColumn": 19 } ], @@ -78,19 +78,19 @@ "severity": "ERROR" }, { - "line": 31, + "line": 32, "column": 17, - "endLine": 31, + "endLine": 32, "endColumn": 19, "problem": "NumericSemantics", "autofix": [ { - "start": 914, - "end": 916, + "start": 963, + "end": 965, "replacementText": "30.0", - "line": 31, + "line": 32, "column": 17, - "endLine": 31, + "endLine": 32, "endColumn": 19 } ], @@ -99,19 +99,19 @@ "severity": "ERROR" }, { - "line": 32, + "line": 33, "column": 14, - "endLine": 32, + "endLine": 33, "endColumn": 17, "problem": "NumericSemantics", "autofix": [ { - "start": 931, - "end": 934, + "start": 980, + "end": 983, "replacementText": "100.0", - "line": 32, + "line": 33, "column": 14, - "endLine": 32, + "endLine": 33, "endColumn": 17 } ], @@ -120,19 +120,19 @@ "severity": "ERROR" }, { - "line": 33, + "line": 34, "column": 15, - "endLine": 33, + "endLine": 34, "endColumn": 18, "problem": "NumericSemantics", "autofix": [ { - "start": 950, - "end": 953, + "start": 999, + "end": 1002, "replacementText": "100.0", - "line": 33, + "line": 34, "column": 15, - "endLine": 33, + "endLine": 34, "endColumn": 18 } ], @@ -141,19 +141,19 @@ "severity": "ERROR" }, { - "line": 34, + "line": 35, "column": 20, - "endLine": 34, + "endLine": 35, "endColumn": 21, "problem": "NumericSemantics", "autofix": [ { - "start": 974, - "end": 975, + "start": 1023, + "end": 1024, "replacementText": "2.0", - "line": 34, + "line": 35, "column": 20, - "endLine": 34, + "endLine": 35, "endColumn": 21 } ], @@ -162,19 +162,19 @@ "severity": "ERROR" }, { - "line": 35, + "line": 36, "column": 20, - "endLine": 35, + "endLine": 36, "endColumn": 22, "problem": "NumericSemantics", "autofix": [ { - "start": 996, - "end": 998, + "start": 1045, + "end": 1047, "replacementText": "10.0", - "line": 35, + "line": 36, "column": 20, - "endLine": 35, + "endLine": 36, "endColumn": 22 } ], @@ -183,19 +183,19 @@ "severity": "ERROR" }, { - "line": 35, + "line": 36, "column": 27, - "endLine": 35, + "endLine": 36, "endColumn": 29, "problem": "NumericSemantics", "autofix": [ { - "start": 1003, - "end": 1005, + "start": 1052, + "end": 1054, "replacementText": "20.0", - "line": 35, + "line": 36, "column": 27, - "endLine": 35, + "endLine": 36, "endColumn": 29 } ], @@ -204,40 +204,40 @@ "severity": "ERROR" }, { - "line": 40, + "line": 41, "column": 8, - "endLine": 40, + "endLine": 41, "endColumn": 21, "problem": "CustomLayoutNeedAddDecorator", "autofix": [ { - "start": 1027, - "end": 1027, - "replacementText": "\n@Layoutable", - "line": 40, + "start": 1076, + "end": 1076, + "replacementText": "\n@CustomLayout", + "line": 41, "column": 8, - "endLine": 40, + "endLine": 41, "endColumn": 21 } ], "suggest": "", - "rule": "Custom components with custom layout capability need to add the \"@Layoutable\" decorator (arkui-custom-layout-need-add-decorator)", + "rule": "Custom components with custom layout capability need to add the \"@CustomLayout\" decorator (arkui-custom-layout-need-add-decorator)", "severity": "ERROR" }, { - "line": 46, + "line": 47, "column": 30, - "endLine": 46, + "endLine": 47, "endColumn": 33, "problem": "NumericSemantics", "autofix": [ { - "start": 1181, - "end": 1184, + "start": 1230, + "end": 1233, "replacementText": "100.0", - "line": 46, + "line": 47, "column": 30, - "endLine": 46, + "endLine": 47, "endColumn": 33 } ], @@ -246,19 +246,19 @@ "severity": "ERROR" }, { - "line": 48, + "line": 49, "column": 12, - "endLine": 48, + "endLine": 49, "endColumn": 13, "problem": "NumericSemantics", "autofix": [ { - "start": 1222, - "end": 1223, + "start": 1271, + "end": 1272, "replacementText": "0.0", - "line": 48, + "line": 49, "column": 12, - "endLine": 48, + "endLine": 49, "endColumn": 13 } ], @@ -267,19 +267,19 @@ "severity": "ERROR" }, { - "line": 49, + "line": 50, "column": 13, - "endLine": 49, + "endLine": 50, "endColumn": 14, "problem": "NumericSemantics", "autofix": [ { - "start": 1237, - "end": 1238, + "start": 1286, + "end": 1287, "replacementText": "0.0", - "line": 49, + "line": 50, "column": 13, - "endLine": 49, + "endLine": 50, "endColumn": 14 } ], @@ -288,19 +288,19 @@ "severity": "ERROR" }, { - "line": 53, + "line": 54, "column": 9, - "endLine": 53, + "endLine": 54, "endColumn": 23, "problem": "NumericSemantics", "autofix": [ { - "start": 1367, - "end": 1381, + "start": 1416, + "end": 1430, "replacementText": "startPos: number = 300", - "line": 53, + "line": 54, "column": 9, - "endLine": 53, + "endLine": 54, "endColumn": 23 } ], @@ -309,19 +309,19 @@ "severity": "ERROR" }, { - "line": 53, + "line": 54, "column": 20, - "endLine": 53, + "endLine": 54, "endColumn": 23, "problem": "NumericSemantics", "autofix": [ { - "start": 1378, - "end": 1381, + "start": 1427, + "end": 1430, "replacementText": "300.0", - "line": 53, + "line": 54, "column": 20, - "endLine": 53, + "endLine": 54, "endColumn": 23 } ], @@ -330,19 +330,19 @@ "severity": "ERROR" }, { - "line": 55, + "line": 56, "column": 11, - "endLine": 55, + "endLine": 56, "endColumn": 54, "problem": "NumericSemantics", "autofix": [ { - "start": 1427, - "end": 1470, + "start": 1476, + "end": 1519, "replacementText": "pos: number = startPos - child.measureResult.height", - "line": 55, + "line": 56, "column": 11, - "endLine": 55, + "endLine": 56, "endColumn": 54 } ], @@ -351,40 +351,40 @@ "severity": "ERROR" }, { - "line": 66, + "line": 67, "column": 8, - "endLine": 66, + "endLine": 67, "endColumn": 21, "problem": "CustomLayoutNeedAddDecorator", "autofix": [ { - "start": 1571, - "end": 1571, - "replacementText": "\n@Layoutable", - "line": 66, + "start": 1620, + "end": 1620, + "replacementText": "\n@CustomLayout", + "line": 67, "column": 8, - "endLine": 66, + "endLine": 67, "endColumn": 21 } ], "suggest": "", - "rule": "Custom components with custom layout capability need to add the \"@Layoutable\" decorator (arkui-custom-layout-need-add-decorator)", + "rule": "Custom components with custom layout capability need to add the \"@CustomLayout\" decorator (arkui-custom-layout-need-add-decorator)", "severity": "ERROR" }, { - "line": 72, + "line": 73, "column": 30, - "endLine": 72, + "endLine": 73, "endColumn": 33, "problem": "NumericSemantics", "autofix": [ { - "start": 1725, - "end": 1728, + "start": 1774, + "end": 1777, "replacementText": "100.0", - "line": 72, + "line": 73, "column": 30, - "endLine": 72, + "endLine": 73, "endColumn": 33 } ], @@ -393,19 +393,19 @@ "severity": "ERROR" }, { - "line": 74, + "line": 75, "column": 12, - "endLine": 74, + "endLine": 75, "endColumn": 13, "problem": "NumericSemantics", "autofix": [ { - "start": 1766, - "end": 1767, + "start": 1815, + "end": 1816, "replacementText": "0.0", - "line": 74, + "line": 75, "column": 12, - "endLine": 74, + "endLine": 75, "endColumn": 13 } ], @@ -414,19 +414,19 @@ "severity": "ERROR" }, { - "line": 75, + "line": 76, "column": 13, - "endLine": 75, + "endLine": 76, "endColumn": 14, "problem": "NumericSemantics", "autofix": [ { - "start": 1781, - "end": 1782, + "start": 1830, + "end": 1831, "replacementText": "0.0", - "line": 75, + "line": 76, "column": 13, - "endLine": 75, + "endLine": 76, "endColumn": 14 } ], @@ -435,19 +435,19 @@ "severity": "ERROR" }, { - "line": 79, + "line": 80, "column": 9, - "endLine": 79, + "endLine": 80, "endColumn": 19, "problem": "NumericSemantics", "autofix": [ { - "start": 1909, - "end": 1919, + "start": 1958, + "end": 1968, "replacementText": "size: number = 100", - "line": 79, + "line": 80, "column": 9, - "endLine": 79, + "endLine": 80, "endColumn": 19 } ], @@ -456,19 +456,19 @@ "severity": "ERROR" }, { - "line": 79, + "line": 80, "column": 16, - "endLine": 79, + "endLine": 80, "endColumn": 19, "problem": "NumericSemantics", "autofix": [ { - "start": 1916, - "end": 1919, + "start": 1965, + "end": 1968, "replacementText": "100.0", - "line": 79, + "line": 80, "column": 16, - "endLine": 79, + "endLine": 80, "endColumn": 19 } ], @@ -477,19 +477,19 @@ "severity": "ERROR" }, { - "line": 82, + "line": 83, "column": 30, - "endLine": 82, + "endLine": 83, "endColumn": 31, "problem": "NumericSemantics", "autofix": [ { - "start": 2102, - "end": 2103, + "start": 2151, + "end": 2152, "replacementText": "2.0", - "line": 82, + "line": 83, "column": 30, - "endLine": 82, + "endLine": 83, "endColumn": 31 } ], @@ -498,19 +498,19 @@ "severity": "ERROR" }, { - "line": 85, + "line": 86, "column": 25, - "endLine": 85, + "endLine": 86, "endColumn": 28, "problem": "NumericSemantics", "autofix": [ { - "start": 2143, - "end": 2146, + "start": 2192, + "end": 2195, "replacementText": "100.0", - "line": 85, + "line": 86, "column": 25, - "endLine": 85, + "endLine": 86, "endColumn": 28 } ], @@ -519,19 +519,19 @@ "severity": "ERROR" }, { - "line": 86, + "line": 87, "column": 26, - "endLine": 86, + "endLine": 87, "endColumn": 29, "problem": "NumericSemantics", "autofix": [ { - "start": 2173, - "end": 2176, + "start": 2222, + "end": 2225, "replacementText": "400.0", - "line": 86, + "line": 87, "column": 26, - "endLine": 86, + "endLine": 87, "endColumn": 29 } ], @@ -541,207 +541,449 @@ }, { "line": 97, - "column": 3, + "column": 8, "endLine": 97, - "endColumn": 8, - "problem": "AnyType", + "endColumn": 21, + "problem": "CustomLayoutNeedAddDecorator", + "autofix": [ + { + "start": 2304, + "end": 2304, + "replacementText": "\n@CustomLayout", + "line": 97, + "column": 8, + "endLine": 97, + "endColumn": 21 + } + ], "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Custom components with custom layout capability need to add the \"@CustomLayout\" decorator (arkui-custom-layout-need-add-decorator)", "severity": "ERROR" }, { - "line": 16, - "column": 2, - "endLine": 16, - "endColumn": 7, - "problem": "UIInterfaceImport", + "line": 103, + "column": 30, + "endLine": 103, + "endColumn": 33, + "problem": "NumericSemantics", "autofix": [ { - "start": 603, - "end": 603, - "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", - "line": 95, - "column": 2, - "endLine": 95, - "endColumn": 11 + "start": 2458, + "end": 2461, + "replacementText": "100.0", + "line": 103, + "column": 30, + "endLine": 103, + "endColumn": 33 } ], "suggest": "", - "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, { - "line": 17, - "column": 2, - "endLine": 17, - "endColumn": 11, - "problem": "UIInterfaceImport", + "line": 105, + "column": 12, + "endLine": 105, + "endColumn": 13, + "problem": "NumericSemantics", "autofix": [ { - "start": 603, - "end": 603, - "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", - "line": 95, - "column": 2, - "endLine": 95, - "endColumn": 11 + "start": 2499, + "end": 2500, + "replacementText": "0.0", + "line": 105, + "column": 12, + "endLine": 105, + "endColumn": 13 } ], "suggest": "", - "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, { - "line": 20, - "column": 5, - "endLine": 20, - "endColumn": 11, - "problem": "UIInterfaceImport", + "line": 106, + "column": 13, + "endLine": 106, + "endColumn": 14, + "problem": "NumericSemantics", "autofix": [ { - "start": 603, - "end": 603, - "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", - "line": 95, - "column": 2, - "endLine": 95, - "endColumn": 11 + "start": 2514, + "end": 2515, + "replacementText": "0.0", + "line": 106, + "column": 13, + "endLine": 106, + "endColumn": 14 } ], "suggest": "", - "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, { - "line": 27, - "column": 2, - "endLine": 27, - "endColumn": 9, - "problem": "UIInterfaceImport", + "line": 110, + "column": 9, + "endLine": 110, + "endColumn": 19, + "problem": "NumericSemantics", "autofix": [ { - "start": 603, - "end": 603, - "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", - "line": 95, - "column": 2, - "endLine": 95, - "endColumn": 11 + "start": 2642, + "end": 2652, + "replacementText": "size: number = 100", + "line": 110, + "column": 9, + "endLine": 110, + "endColumn": 19 } ], "suggest": "", - "rule": "The ArkUI interface \"Builder\" should be imported before it is used (arkui-modular-interface)", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, { - "line": 29, - "column": 3, - "endLine": 29, - "endColumn": 10, - "problem": "UIInterfaceImport", + "line": 110, + "column": 16, + "endLine": 110, + "endColumn": 19, + "problem": "NumericSemantics", "autofix": [ { - "start": 603, - "end": 603, - "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", - "line": 95, - "column": 2, - "endLine": 95, - "endColumn": 11 + "start": 2649, + "end": 2652, + "replacementText": "100.0", + "line": 110, + "column": 16, + "endLine": 110, + "endColumn": 19 } ], "suggest": "", - "rule": "The ArkUI interface \"ForEach\" should be imported before it is used (arkui-modular-interface)", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, { - "line": 30, - "column": 5, - "endLine": 30, - "endColumn": 9, - "problem": "UIInterfaceImport", + "line": 113, + "column": 30, + "endLine": 113, + "endColumn": 31, + "problem": "NumericSemantics", "autofix": [ { - "start": 603, - "end": 603, - "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", - "line": 95, - "column": 2, - "endLine": 95, - "endColumn": 11 + "start": 2835, + "end": 2836, + "replacementText": "2.0", + "line": 113, + "column": 30, + "endLine": 113, + "endColumn": 31 } ], "suggest": "", - "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, { - "line": 39, - "column": 2, - "endLine": 39, - "endColumn": 11, - "problem": "UIInterfaceImport", + "line": 115, + "column": 25, + "endLine": 115, + "endColumn": 28, + "problem": "NumericSemantics", "autofix": [ { - "start": 603, - "end": 603, - "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", - "line": 95, - "column": 2, - "endLine": 95, - "endColumn": 11 + "start": 2869, + "end": 2872, + "replacementText": "100.0", + "line": 115, + "column": 25, + "endLine": 115, + "endColumn": 28 } ], "suggest": "", - "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, { - "line": 41, - "column": 4, - "endLine": 41, - "endColumn": 11, - "problem": "UIInterfaceImport", + "line": 116, + "column": 26, + "endLine": 116, + "endColumn": 29, + "problem": "NumericSemantics", "autofix": [ { - "start": 603, - "end": 603, - "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", - "line": 95, - "column": 2, - "endLine": 95, - "endColumn": 11 + "start": 2899, + "end": 2902, + "replacementText": "400.0", + "line": 116, + "column": 26, + "endLine": 116, + "endColumn": 29 } ], "suggest": "", - "rule": "The ArkUI interface \"Builder\" should be imported before it is used (arkui-modular-interface)", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, { - "line": 45, - "column": 4, - "endLine": 45, - "endColumn": 16, - "problem": "UIInterfaceImport", + "line": 121, + "column": 9, + "endLine": 121, + "endColumn": 23, + "problem": "NumericSemantics", "autofix": [ { - "start": 603, - "end": 603, + "start": 3055, + "end": 3069, + "replacementText": "startPos: number = 300", + "line": 121, + "column": 9, + "endLine": 121, + "endColumn": 23 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 121, + "column": 20, + "endLine": 121, + "endColumn": 23, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 3066, + "end": 3069, + "replacementText": "300.0", + "line": 121, + "column": 20, + "endLine": 121, + "endColumn": 23 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 123, + "column": 11, + "endLine": 123, + "endColumn": 54, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 3115, + "end": 3158, + "replacementText": "pos: number = startPos - child.measureResult.height", + "line": 123, + "column": 11, + "endLine": 123, + "endColumn": 54 + } + ], + "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, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", - "line": 95, + "line": 133, "column": 2, - "endLine": 95, + "endLine": 133, "endColumn": 11 } ], "suggest": "", - "rule": "The ArkUI interface \"BuilderParam\" should be imported before it is used (arkui-modular-interface)", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 2, + "endLine": 17, + "endColumn": 11, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", + "line": 133, + "column": 2, + "endLine": 133, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 5, + "endLine": 20, + "endColumn": 11, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", + "line": 133, + "column": 2, + "endLine": 133, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 2, + "endLine": 28, + "endColumn": 9, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", + "line": 133, + "column": 2, + "endLine": 133, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Builder\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 3, + "endLine": 30, + "endColumn": 10, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", + "line": 133, + "column": 2, + "endLine": 133, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"ForEach\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 5, + "endLine": 31, + "endColumn": 9, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", + "line": 133, + "column": 2, + "endLine": 133, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 2, + "endLine": 40, + "endColumn": 11, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", + "line": 133, + "column": 2, + "endLine": 133, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 4, + "endLine": 42, + "endColumn": 11, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", + "line": 133, + "column": 2, + "endLine": 133, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Builder\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { "line": 46, "column": 4, "endLine": 46, + "endColumn": 16, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", + "line": 133, + "column": 2, + "endLine": 133, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"BuilderParam\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 47, + "column": 4, + "endLine": 47, "endColumn": 9, "problem": "UIInterfaceImport", "autofix": [ @@ -749,9 +991,9 @@ "start": 603, "end": 603, "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", - "line": 95, + "line": 133, "column": 2, - "endLine": 95, + "endLine": 133, "endColumn": 11 } ], @@ -760,9 +1002,9 @@ "severity": "ERROR" }, { - "line": 47, + "line": 48, "column": 11, - "endLine": 47, + "endLine": 48, "endColumn": 21, "problem": "UIInterfaceImport", "autofix": [ @@ -770,9 +1012,9 @@ "start": 603, "end": 603, "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", - "line": 95, + "line": 133, "column": 2, - "endLine": 95, + "endLine": 133, "endColumn": 11 } ], @@ -781,9 +1023,9 @@ "severity": "ERROR" }, { - "line": 52, + "line": 53, "column": 35, - "endLine": 52, + "endLine": 53, "endColumn": 47, "problem": "UIInterfaceImport", "autofix": [ @@ -791,9 +1033,9 @@ "start": 603, "end": 603, "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", - "line": 95, + "line": 133, "column": 2, - "endLine": 95, + "endLine": 133, "endColumn": 11 } ], @@ -802,9 +1044,9 @@ "severity": "ERROR" }, { - "line": 52, + "line": 53, "column": 65, - "endLine": 52, + "endLine": 53, "endColumn": 75, "problem": "UIInterfaceImport", "autofix": [ @@ -812,9 +1054,9 @@ "start": 603, "end": 603, "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", - "line": 95, + "line": 133, "column": 2, - "endLine": 95, + "endLine": 133, "endColumn": 11 } ], @@ -823,9 +1065,9 @@ "severity": "ERROR" }, { - "line": 52, + "line": 53, "column": 90, - "endLine": 52, + "endLine": 53, "endColumn": 111, "problem": "UIInterfaceImport", "autofix": [ @@ -833,9 +1075,9 @@ "start": 603, "end": 603, "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", - "line": 95, + "line": 133, "column": 2, - "endLine": 95, + "endLine": 133, "endColumn": 11 } ], @@ -844,9 +1086,9 @@ "severity": "ERROR" }, { - "line": 65, + "line": 66, "column": 2, - "endLine": 65, + "endLine": 66, "endColumn": 11, "problem": "UIInterfaceImport", "autofix": [ @@ -854,9 +1096,9 @@ "start": 603, "end": 603, "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", - "line": 95, + "line": 133, "column": 2, - "endLine": 95, + "endLine": 133, "endColumn": 11 } ], @@ -865,9 +1107,9 @@ "severity": "ERROR" }, { - "line": 67, + "line": 68, "column": 4, - "endLine": 67, + "endLine": 68, "endColumn": 11, "problem": "UIInterfaceImport", "autofix": [ @@ -875,9 +1117,9 @@ "start": 603, "end": 603, "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", - "line": 95, + "line": 133, "column": 2, - "endLine": 95, + "endLine": 133, "endColumn": 11 } ], @@ -886,9 +1128,9 @@ "severity": "ERROR" }, { - "line": 71, + "line": 72, "column": 4, - "endLine": 71, + "endLine": 72, "endColumn": 16, "problem": "UIInterfaceImport", "autofix": [ @@ -896,9 +1138,9 @@ "start": 603, "end": 603, "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", - "line": 95, + "line": 133, "column": 2, - "endLine": 95, + "endLine": 133, "endColumn": 11 } ], @@ -907,9 +1149,9 @@ "severity": "ERROR" }, { - "line": 72, + "line": 73, "column": 4, - "endLine": 72, + "endLine": 73, "endColumn": 9, "problem": "UIInterfaceImport", "autofix": [ @@ -917,9 +1159,9 @@ "start": 603, "end": 603, "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", - "line": 95, + "line": 133, "column": 2, - "endLine": 95, + "endLine": 133, "endColumn": 11 } ], @@ -928,9 +1170,9 @@ "severity": "ERROR" }, { - "line": 73, + "line": 74, "column": 11, - "endLine": 73, + "endLine": 74, "endColumn": 21, "problem": "UIInterfaceImport", "autofix": [ @@ -938,9 +1180,9 @@ "start": 603, "end": 603, "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", - "line": 95, + "line": 133, "column": 2, - "endLine": 95, + "endLine": 133, "endColumn": 11 } ], @@ -949,9 +1191,9 @@ "severity": "ERROR" }, { - "line": 78, + "line": 79, "column": 33, - "endLine": 78, + "endLine": 79, "endColumn": 45, "problem": "UIInterfaceImport", "autofix": [ @@ -959,9 +1201,9 @@ "start": 603, "end": 603, "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", - "line": 95, + "line": 133, "column": 2, - "endLine": 95, + "endLine": 133, "endColumn": 11 } ], @@ -970,9 +1212,9 @@ "severity": "ERROR" }, { - "line": 78, + "line": 79, "column": 63, - "endLine": 78, + "endLine": 79, "endColumn": 73, "problem": "UIInterfaceImport", "autofix": [ @@ -980,9 +1222,9 @@ "start": 603, "end": 603, "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", - "line": 95, + "line": 133, "column": 2, - "endLine": 95, + "endLine": 133, "endColumn": 11 } ], @@ -991,9 +1233,9 @@ "severity": "ERROR" }, { - "line": 78, + "line": 79, "column": 88, - "endLine": 78, + "endLine": 79, "endColumn": 109, "problem": "UIInterfaceImport", "autofix": [ @@ -1001,9 +1243,9 @@ "start": 603, "end": 603, "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", - "line": 95, + "line": 133, "column": 2, - "endLine": 95, + "endLine": 133, "endColumn": 11 } ], @@ -1012,9 +1254,9 @@ "severity": "ERROR" }, { - "line": 81, + "line": 82, "column": 19, - "endLine": 81, + "endLine": 82, "endColumn": 32, "problem": "UIInterfaceImport", "autofix": [ @@ -1022,9 +1264,9 @@ "start": 603, "end": 603, "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", - "line": 95, + "line": 133, "column": 2, - "endLine": 95, + "endLine": 133, "endColumn": 11 } ], @@ -1033,9 +1275,261 @@ "severity": "ERROR" }, { - "line": 95, + "line": 96, + "column": 2, + "endLine": 96, + "endColumn": 11, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", + "line": 133, + "column": 2, + "endLine": 133, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 98, + "column": 4, + "endLine": 98, + "endColumn": 11, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", + "line": 133, + "column": 2, + "endLine": 133, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Builder\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 102, + "column": 4, + "endLine": 102, + "endColumn": 16, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", + "line": 133, + "column": 2, + "endLine": 133, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"BuilderParam\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 103, + "column": 4, + "endLine": 103, + "endColumn": 9, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", + "line": 133, + "column": 2, + "endLine": 133, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 104, + "column": 11, + "endLine": 104, + "endColumn": 21, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", + "line": 133, + "column": 2, + "endLine": 133, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"SizeResult\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 109, + "column": 33, + "endLine": 109, + "endColumn": 45, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", + "line": 133, + "column": 2, + "endLine": 133, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"GeometryInfo\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 109, + "column": 63, + "endLine": 109, + "endColumn": 73, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", + "line": 133, + "column": 2, + "endLine": 133, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Measurable\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 109, + "column": 88, + "endLine": 109, + "endColumn": 109, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", + "line": 133, + "column": 2, + "endLine": 133, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"ConstraintSizeOptions\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 112, + "column": 19, + "endLine": 112, + "endColumn": 32, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", + "line": 133, + "column": 2, + "endLine": 133, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"MeasureResult\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 120, + "column": 35, + "endLine": 120, + "endColumn": 47, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", + "line": 133, + "column": 2, + "endLine": 133, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"GeometryInfo\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 120, + "column": 65, + "endLine": 120, + "endColumn": 75, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", + "line": 133, + "column": 2, + "endLine": 133, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Layoutable\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 120, + "column": 90, + "endLine": 120, + "endColumn": 111, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", + "line": 133, + "column": 2, + "endLine": 133, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"ConstraintSizeOptions\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 133, "column": 2, - "endLine": 95, + "endLine": 133, "endColumn": 11, "problem": "UIInterfaceImport", "autofix": [ @@ -1043,9 +1537,9 @@ "start": 603, "end": 603, "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", - "line": 95, + "line": 133, "column": 2, - "endLine": 95, + "endLine": 133, "endColumn": 11 } ], diff --git a/ets2panda/linter/test/main/custom_layout.ets.json b/ets2panda/linter/test/main/custom_layout.ets.json index 5d769b466be894ca7e944a9048b170f15ac0ae1c..cc51fe6a1b8579dfc9a96d92c8fb908c4660e35a 100644 --- a/ets2panda/linter/test/main/custom_layout.ets.json +++ b/ets2panda/linter/test/main/custom_layout.ets.json @@ -15,9 +15,9 @@ ], "result": [ { - "line": 78, + "line": 79, "column": 3, - "endLine": 78, + "endLine": 79, "endColumn": 16, "problem": "LimitedReturnTypeInference", "suggest": "", @@ -25,13 +25,13 @@ "severity": "ERROR" }, { - "line": 97, + "line": 109, "column": 3, - "endLine": 97, - "endColumn": 8, - "problem": "AnyType", + "endLine": 109, + "endColumn": 16, + "problem": "LimitedReturnTypeInference", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Function return type inference is limited (arkts-no-implicit-return-types)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/main/custom_layout.ets.migrate.ets b/ets2panda/linter/test/main/custom_layout.ets.migrate.ets index 97dd101026b6341d1c89f2b955d001b79a3e420d..5053380e4c88ac8b5a22585630602e23ec549ef2 100644 --- a/ets2panda/linter/test/main/custom_layout.ets.migrate.ets +++ b/ets2panda/linter/test/main/custom_layout.ets.migrate.ets @@ -13,6 +13,8 @@ * limitations under the License. */ +import { CustomLayout } from '@kit.ArkUI'; + import { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI'; @Entry @@ -22,6 +24,7 @@ struct Index { Column() { CustomLayout1({ builder: ColumnChildren }) CustomLayout2({ builder: ColumnChildren }) + CustomLayout3({ builder: ColumnChildren }) } } } @@ -39,7 +42,7 @@ function ColumnChildren() { } @Component -@Layoutable +@CustomLayout struct CustomLayout1 { @Builder doNothingBuilder() { @@ -66,7 +69,7 @@ struct CustomLayout1 { } @Component -@Layoutable +@CustomLayout struct CustomLayout2 { @Builder doNothingBuilder() { @@ -97,8 +100,46 @@ struct CustomLayout2 { } @Component +@CustomLayout struct CustomLayout3 { - build { + @Builder + doNothingBuilder() { + }; + + @BuilderParam builder: () => void = this.doNothingBuilder; + @State startSize: number = 100.0; + result: SizeResult = { + width: 0.0, + height: 0.0 + }; + + onMeasureSize(selfLayoutInfo: GeometryInfo, children: Array, constraint: ConstraintSizeOptions) { + let size: number = 100.0; + children.forEach((child) => { + let result: MeasureResult = child.measure({ minHeight: size, minWidth: size, maxWidth: size, maxHeight: size }) + size += result.width / 2.0; + }) + this.result.width = 100.0; + this.result.height = 400.0; + return this.result; + } + + onPlaceChildren(selfLayoutInfo: GeometryInfo, children: Array, constraint: ConstraintSizeOptions) { + let startPos: number = 300.0; + children.forEach((child) => { + let pos: number = startPos - child.measureResult.height; + child.layout({ x: pos, y: pos }) + }) + } + + build() { + this.builder() + } +} + +@Component +struct CustomLayout4 { + build() { } } \ No newline at end of file diff --git a/ets2panda/linter/test/main/custom_layout.ets.migrate.json b/ets2panda/linter/test/main/custom_layout.ets.migrate.json index 6c283c3ef1beea2a8d290ae40cecd19853e44771..21ac1fc70cfda7b0747e4d1f3deda42f66986334 100644 --- a/ets2panda/linter/test/main/custom_layout.ets.migrate.json +++ b/ets2panda/linter/test/main/custom_layout.ets.migrate.json @@ -15,33 +15,33 @@ ], "result": [ { - "line": 42, + "line": 45, "column": 1, - "endLine": 42, - "endColumn": 12, + "endLine": 45, + "endColumn": 14, "problem": "DecoratorsNotSupported", "suggest": "", "rule": "Decorators are not supported(arkts-no-ts-decorators)", "severity": "ERROR" }, { - "line": 69, + "line": 72, "column": 1, - "endLine": 69, - "endColumn": 12, + "endLine": 72, + "endColumn": 14, "problem": "DecoratorsNotSupported", "suggest": "", "rule": "Decorators are not supported(arkts-no-ts-decorators)", "severity": "ERROR" }, { - "line": 101, - "column": 3, - "endLine": 101, - "endColumn": 8, - "problem": "AnyType", + "line": 103, + "column": 1, + "endLine": 103, + "endColumn": 14, + "problem": "DecoratorsNotSupported", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Decorators are not supported(arkts-no-ts-decorators)", "severity": "ERROR" } ]