diff --git a/arkui-plugins/common/predefines.ts b/arkui-plugins/common/predefines.ts index b180fdddc1f06615bcb55d71ce08e624577e6e01..65e0f8b3c811b0c23696fd20da9e6a7f64931c7d 100644 --- a/arkui-plugins/common/predefines.ts +++ b/arkui-plugins/common/predefines.ts @@ -124,7 +124,6 @@ export enum InnerComponentNames { export enum DecoratorNames { STATE = 'State', STORAGE_LINK = 'StorageLink', - STORAGE_PROP = 'StorageProp', LINK = 'Link', PROP = 'Prop', PROVIDE = 'Provide', @@ -136,7 +135,6 @@ export enum DecoratorNames { BUILDER_PARAM = 'BuilderParam', BUILDER = 'Builder', CUSTOM_DIALOG = 'CustomDialog', - LOCAL_STORAGE_PROP = 'LocalStorageProp', LOCAL_STORAGE_LINK = 'LocalStorageLink', REUSABLE = 'Reusable', TRACK = 'Track', @@ -177,7 +175,6 @@ export enum StateManagementTypes { STORAGE_PROP_REF_DECORATED = 'IStoragePropRefDecoratedVariable', LOCAL_STORAGE_LINK_DECORATED = 'ILocalStorageLinkDecoratedVariable', PROP_DECORATED = 'IPropDecoratedVariable', - SYNCED_PROPERTY = 'SyncedProperty', PROVIDE_DECORATED = 'IProvideDecoratedVariable', CONSUME_DECORATED = 'IConsumeDecoratedVariable', OBJECT_LINK_DECORATED = 'IObjectLinkDecoratedVariable', @@ -203,7 +200,6 @@ export enum StateManagementTypes { UPDATE = 'update', MAKE_STATE = 'makeState', MAKE_LINK = 'makeLink', - MAKE_PROP = 'makeProp', MAKE_PROP_REF = 'makePropRef', MAKE_LOCAL = 'makeLocal', MAKE_STATIC_LOCAL = 'makeStaticLocal', @@ -270,13 +266,10 @@ export const RESOURCE_TYPE: Record = { export const DECORATOR_TYPE_MAP = new Map([ [DecoratorNames.STATE, StateManagementTypes.STATE_DECORATED], [DecoratorNames.LINK, StateManagementTypes.LINK_SOURCE_TYPE], - [DecoratorNames.PROP, StateManagementTypes.PROP_DECORATED], [DecoratorNames.PROP_REF, StateManagementTypes.PROP_REF_DECORATED], [DecoratorNames.STORAGE_LINK, StateManagementTypes.STORAGE_LINK_DECORATED], - [DecoratorNames.STORAGE_PROP, StateManagementTypes.STORAGE_PROP_REF_DECORATED], [DecoratorNames.STORAGE_PROP_REF, StateManagementTypes.STORAGE_PROP_REF_DECORATED], [DecoratorNames.LOCAL_STORAGE_PROP_REF, StateManagementTypes.LOCAL_STORAGE_PROP_REF_DECORATED], - [DecoratorNames.LOCAL_STORAGE_PROP, StateManagementTypes.SYNCED_PROPERTY], [DecoratorNames.LOCAL_STORAGE_LINK, StateManagementTypes.LOCAL_STORAGE_LINK_DECORATED], [DecoratorNames.OBJECT_LINK, StateManagementTypes.OBJECT_LINK_DECORATED], [DecoratorNames.PROVIDE, StateManagementTypes.PROVIDE_DECORATED], @@ -294,11 +287,9 @@ export const INTERMEDIATE_IMPORT_SOURCE: Map = new Map = new Map = new Map = new Map([ [Dollars.TRANSFORM_DOLLAR_RESOURCE, 'arkui.component.resources'], [Dollars.TRANSFORM_DOLLAR_RAWFILE, 'arkui.component.resources'], - [StateManagementTypes.SYNCED_PROPERTY, 'arkui.stateManagement.runtime'], [StateManagementTypes.STORAGE_LINK_STATE, 'arkui.stateManagement.runtime'], [StateManagementTypes.OBSERVABLE_PROXY, 'arkui.stateManagement.runtime'], [StateManagementTypes.PROP_STATE, 'arkui.stateManagement.runtime'], diff --git a/arkui-plugins/test/demo/mock/component/declare-component.ets b/arkui-plugins/test/demo/mock/component/declare-component.ets index aa0142368b5354a8d4346902c8ce4f6f43cbdd6c..2241b11639c6016377a913c959a97fb659f45a43 100644 --- a/arkui-plugins/test/demo/mock/component/declare-component.ets +++ b/arkui-plugins/test/demo/mock/component/declare-component.ets @@ -14,12 +14,12 @@ */ import { Component, ResourceStr, Builder} from "@ohos.arkui.component" -import { Prop, State } from "@ohos.arkui.stateManagement" +import { PropRef, State } from "@ohos.arkui.stateManagement" @Component export declare struct SwipeRefresher { - @Prop content?: ResourceStr; - @Prop isLoading: boolean; + @PropRef content?: ResourceStr; + @PropRef isLoading: boolean; @State code: number; @Builder build(): void; diff --git a/arkui-plugins/test/demo/mock/decorators/custom-dialog/controller-in-build.ets b/arkui-plugins/test/demo/mock/decorators/custom-dialog/controller-in-build.ets index c87bc2e13d0018ae043a0da87d0c09b977ab2dba..70c0f411a545d76ef0769c49446f121485f636a9 100644 --- a/arkui-plugins/test/demo/mock/decorators/custom-dialog/controller-in-build.ets +++ b/arkui-plugins/test/demo/mock/decorators/custom-dialog/controller-in-build.ets @@ -14,7 +14,7 @@ */ import { Text, Column, Component, Button, ClickEvent } from "@ohos.arkui.component" -import { State, Link, Prop } from "@ohos.arkui.stateManagement" +import { State } from "@ohos.arkui.stateManagement" import { CustomDialog, CustomDialogController, CustomDialogControllerOptions } from "@kit.ArkUI" import hilog from '@ohos.hilog' diff --git a/arkui-plugins/test/demo/mock/decorators/custom-dialog/controller-in-method.ets b/arkui-plugins/test/demo/mock/decorators/custom-dialog/controller-in-method.ets index 677b6298247ae00a1f46507529f406db63463837..f93d2e3e78b37fd62cc75d9aab9c0eccad71e684 100644 --- a/arkui-plugins/test/demo/mock/decorators/custom-dialog/controller-in-method.ets +++ b/arkui-plugins/test/demo/mock/decorators/custom-dialog/controller-in-method.ets @@ -14,7 +14,6 @@ */ import { Component, CustomDialog, CustomDialogController } from "@ohos.arkui.component" -import hilog from '@ohos.hilog' @CustomDialog struct CustomDialogExample { diff --git a/arkui-plugins/test/demo/mock/decorators/decorator-no-type.ets b/arkui-plugins/test/demo/mock/decorators/decorator-no-type.ets index 65065c3e573871304305edf1856f30a5c953a00e..bbc995929e3b5441fc770df1a1155ddf871dabc3 100644 --- a/arkui-plugins/test/demo/mock/decorators/decorator-no-type.ets +++ b/arkui-plugins/test/demo/mock/decorators/decorator-no-type.ets @@ -14,7 +14,7 @@ */ import { Component, ComponentV2, CustomDialog } from "@ohos.arkui.component" -import { State, Prop, Provide, Event, Local, Param } from "@ohos.arkui.stateManagement" +import { State, PropRef, Provide, Event, Local, Param } from "@ohos.arkui.stateManagement" import { Provider, Consumer, Once, Observed, ObservedV2, Trace, Track } from "@ohos.arkui.stateManagement" class Per { @@ -44,7 +44,7 @@ class RR { @Component struct Parent { @State stateVar1 = new Per(6); - @Prop stateVar2 = new Array(3, 6, 8); + @PropRef stateVar2 = new Array(3, 6, 8); @Provide stateVar3 = StateType.TYPE3; stateVar8 = (sr: string) => { }; diff --git a/arkui-plugins/test/demo/mock/decorators/link/link-to-link-prop-state.ets b/arkui-plugins/test/demo/mock/decorators/link/link-to-link-propref-state.ets similarity index 88% rename from arkui-plugins/test/demo/mock/decorators/link/link-to-link-prop-state.ets rename to arkui-plugins/test/demo/mock/decorators/link/link-to-link-propref-state.ets index b04d84e93c8f0f6e83a0be4e0afb54c5704d60aa..70275e71b7ee837e4e38dcf674b415e3ca97b264 100644 --- a/arkui-plugins/test/demo/mock/decorators/link/link-to-link-prop-state.ets +++ b/arkui-plugins/test/demo/mock/decorators/link/link-to-link-propref-state.ets @@ -14,7 +14,7 @@ */ import { Component, Column, TextInput } from "@ohos.arkui.component" -import { Link, State, Prop } from "@ohos.arkui.stateManagement" +import { Link, State, PropRef } from "@ohos.arkui.stateManagement" @Component struct Parant { @@ -32,8 +32,8 @@ struct Parant { struct Child { @Link childText: string; @State childText2: string = 'sss'; - @Prop childText3: string; - @Prop childText4: string = 'cc'; + @PropRef childText3: string; + @PropRef childText4: string = 'cc'; build() { TextInput({ text: this.childText }) diff --git a/arkui-plugins/test/demo/mock/decorators/localstoragelink/localstoragelink-complex-type.ets b/arkui-plugins/test/demo/mock/decorators/localstoragelink/localstoragelink-complex-type.ets index 4a1099b23f4a7f05e2293c4b53baa2ddac583ac1..6a2f5d19630c69860912683c2b62a6422b22f6fd 100644 --- a/arkui-plugins/test/demo/mock/decorators/localstoragelink/localstoragelink-complex-type.ets +++ b/arkui-plugins/test/demo/mock/decorators/localstoragelink/localstoragelink-complex-type.ets @@ -35,7 +35,7 @@ struct MyStateSample { @LocalStorageLink('Prop3') dateA: Date = new Date('2021-08-08'); @LocalStorageLink('Prop4') setA: Set = new Set(); @LocalStorageLink('Prop5') mapA: Map = new Map(); - //@LocalStorageLink('Prop6') unionA: string | undefined = ""; + @LocalStorageLink('Prop6') unionA: string | undefined = ""; @LocalStorageLink('Prop7') classA: Person = new Person("John"); @LocalStorageLink('Prop8') enumA: Status = Status.NotFound; diff --git a/arkui-plugins/test/demo/mock/decorators/localstorageprop-ref/localstorageprop-ref-complex-type.ets b/arkui-plugins/test/demo/mock/decorators/localstorageprop-ref/localstorageprop-ref-complex-type.ets index 72cc3f9c772a57ad4d743dd8a2a1a96116257569..7e8a2bd1d2bbfd18fe1fddcadd4011980acc27c3 100644 --- a/arkui-plugins/test/demo/mock/decorators/localstorageprop-ref/localstorageprop-ref-complex-type.ets +++ b/arkui-plugins/test/demo/mock/decorators/localstorageprop-ref/localstorageprop-ref-complex-type.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -import { Component } from "@ohos.arkui.component" // TextAttribute should be insert by ui-plugins +import { Component } from "@ohos.arkui.component" import { LocalStoragePropRef } from "@ohos.arkui.stateManagement" class Person{ diff --git a/arkui-plugins/test/demo/mock/decorators/prop/prop-basic-type.ets b/arkui-plugins/test/demo/mock/decorators/prop/prop-basic-type.ets deleted file mode 100644 index bcfff2d589ac24d532da6c04ddc2ca008acf5cf0..0000000000000000000000000000000000000000 --- a/arkui-plugins/test/demo/mock/decorators/prop/prop-basic-type.ets +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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 { Component } from "@ohos.arkui.component" -import { Prop } from "@ohos.arkui.stateManagement" - -@Component -struct PropParent { - @Prop propVar1: string = 'propVar1'; - @Prop propVar2: number = 50; - @Prop propVar3: boolean = true; - @Prop propVar4: undefined = undefined; - @Prop propVar5: null = null; - - build() { - } -} \ No newline at end of file diff --git a/arkui-plugins/test/demo/mock/decorators/prop/prop-complex-type.ets b/arkui-plugins/test/demo/mock/decorators/prop/prop-complex-type.ets deleted file mode 100644 index a2fbdc9d2387657602f4edd681f64b82a737f645..0000000000000000000000000000000000000000 --- a/arkui-plugins/test/demo/mock/decorators/prop/prop-complex-type.ets +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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 { Component } from "@ohos.arkui.component" -import { Prop } from "@ohos.arkui.stateManagement" - -class Per { - num: number; - constructor(num: number) { - this.num = num; - } -} - -enum PropType { - TYPE1 = 0, - TYPE2 = 1, - TYPE3 = 3 -} - -@Component -struct Parent { - @Prop propVar1: Per = new Per(6); - @Prop propVar2: Array = new Array(3,6,8); - @Prop propVar3: PropType = PropType.TYPE3; - @Prop propVar4: Set = new Set(new Array('aa', 'bb')); - @Prop propVar5: boolean[] = [true, false]; - @Prop propVar6: Array = new Array(new Per(7), new Per(11)); - @Prop propVar7: Per[] = [new Per(7), new Per(11)]; - @Prop propVar8: (sr: string)=>void = (sr: string)=>{}; - @Prop propVar9: Date = new Date('2025-4-23'); - @Prop propVar10: Map = new Map([[0, new Per(7)], [1, new Per(10)]]); - @Prop propVar11: string | number = 0.0; - @Prop propVar12: Set | Per = new Per(6); - - build() { - } -} \ No newline at end of file diff --git a/arkui-plugins/test/demo/mock/decorators/prop/state-to-prop.ets b/arkui-plugins/test/demo/mock/decorators/prop/state-to-prop.ets deleted file mode 100644 index 38af709df0adab049df6551c806c570acaa01019..0000000000000000000000000000000000000000 --- a/arkui-plugins/test/demo/mock/decorators/prop/state-to-prop.ets +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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 { Component, Text, Button, Column, ClickEvent } from "@ohos.arkui.component" -import { Prop, State } from "@ohos.arkui.stateManagement" - -@Component -struct CountDownComponent { - @Prop count: number = 0; - costOfOneAttempt: number = 1; - - build() { - Column() { - if (this.count > 0) { - Text('You have'+ this.count + 'Nuggets left') - } else { - Text('Game over!') - } - Button('Try again').onClick((e: ClickEvent) => { - this.count -= this.costOfOneAttempt; - }) - } - } -} - -@Component -struct ParentComponent { - @State countDownStartValue: number = 10; - - build() { - Column() { - Text('Grant' + this.countDownStartValue + 'nuggets to play.') - Button('+1 - Nuggets in New Game').onClick((e: ClickEvent) => { - this.countDownStartValue += 1; - }) - Button('-1 - Nuggets in New Game').onClick((e: ClickEvent) => { - this.countDownStartValue -= 1; - }) - CountDownComponent({ count: this.countDownStartValue, costOfOneAttempt: 2 }) - } - } -} \ No newline at end of file diff --git a/arkui-plugins/test/demo/mock/decorators/require/basic-require.ets b/arkui-plugins/test/demo/mock/decorators/require/basic-require.ets index 86703f8b58e981eff528f1fd518c952b5a66a735..03bbc9653597f518708a8fb0dd04fffddf285212 100644 --- a/arkui-plugins/test/demo/mock/decorators/require/basic-require.ets +++ b/arkui-plugins/test/demo/mock/decorators/require/basic-require.ets @@ -14,7 +14,7 @@ */ import { Component, ComponentV2, BuilderParam } from "@ohos.arkui.component" -import { State, Require, Prop, Provide, Param } from "@ohos.arkui.stateManagement" +import { State, Require, PropRef, Provide, Param } from "@ohos.arkui.stateManagement" @Component struct MyStateSample { @@ -24,7 +24,7 @@ struct MyStateSample { @Require @State select0: number; @Require @State select3: number | null; @Require @State select4: undefined; - @Require @Prop select1: string; + @Require @PropRef select1: string; @Require @Provide({ alias: '15' }) select2: string[]; @Require @Provide({ alias: 't' }) select6: string[] | undefined | string; @Require @BuilderParam builder: () => void; diff --git a/arkui-plugins/test/demo/mock/decorators/reusable/reusable-basic.ets b/arkui-plugins/test/demo/mock/decorators/reusable/reusable-basic.ets index 547ed62ea0ace3b2aac355c254ae89cf206fd4cf..95aba23334957b3ff81fcc4630dbb2422ab29e8e 100644 --- a/arkui-plugins/test/demo/mock/decorators/reusable/reusable-basic.ets +++ b/arkui-plugins/test/demo/mock/decorators/reusable/reusable-basic.ets @@ -14,19 +14,19 @@ */ import { Component, Reusable} from "@ohos.arkui.component" -import { State, Prop } from "@ohos.arkui.stateManagement" +import { State, PropRef } from "@ohos.arkui.stateManagement" @Component struct MyStateSample { build() { - Child({ num: 5 } ) + Child({ num1: 5 } ) } } @Component @Reusable struct Child { - @Prop num: number = 1 + @PropRef num: number = 1 @State num1: number = 2 build() { diff --git a/arkui-plugins/test/demo/mock/decorators/reusable/reusable-complex.ets b/arkui-plugins/test/demo/mock/decorators/reusable/reusable-complex.ets index 10bf9f803439f53758ecae5b653297554f1150d3..7c5a36a08f545645dd7eaff126ecd54c6277bc0b 100644 --- a/arkui-plugins/test/demo/mock/decorators/reusable/reusable-complex.ets +++ b/arkui-plugins/test/demo/mock/decorators/reusable/reusable-complex.ets @@ -38,7 +38,6 @@ struct Index { this.display = !this.display; }) if (this.display) { - // 如果只有一个复用的组件,可以不用设置reuseId Child({ message: new Message('Child') }) } } @@ -52,10 +51,7 @@ struct Index { struct Child { @State message: Message = new Message('AboutToReuse'); - aboutToReuse(params: Record) { - console.info("Recycle ====Child=="); - //this.message = params.message as Message; - } + aboutToReuse(params: Record) {} build() { Column() { diff --git a/arkui-plugins/test/demo/mock/decorators/state/state-basic-type.ets b/arkui-plugins/test/demo/mock/decorators/state/state-basic-type.ets index b7e039a774cfb91d4069786c69be741ced0e1387..a4f235fb492316a9ac0ade40b5547871d26a6f89 100644 --- a/arkui-plugins/test/demo/mock/decorators/state/state-basic-type.ets +++ b/arkui-plugins/test/demo/mock/decorators/state/state-basic-type.ets @@ -14,7 +14,7 @@ */ import { Component } from "@ohos.arkui.component" -import { State} from "@ohos.arkui.stateManagement" +import { State } from "@ohos.arkui.stateManagement" @Component struct Parent { diff --git a/arkui-plugins/test/demo/mock/decorators/state/state-complex-type.ets b/arkui-plugins/test/demo/mock/decorators/state/state-complex-type.ets index 5ffe6f50afc67bdfa63f3434e3a336541e19df20..01d115bf9c48513a792bb8e07c8f29a466999c54 100644 --- a/arkui-plugins/test/demo/mock/decorators/state/state-complex-type.ets +++ b/arkui-plugins/test/demo/mock/decorators/state/state-complex-type.ets @@ -14,7 +14,7 @@ */ import { Component } from "@ohos.arkui.component" -import { State} from "@ohos.arkui.stateManagement" +import { State } from "@ohos.arkui.stateManagement" class Per { num: number; diff --git a/arkui-plugins/test/demo/mock/decorators/storageprop/storageprop-appstorage.ets b/arkui-plugins/test/demo/mock/decorators/storageprop/storageprop-appstorage.ets deleted file mode 100644 index dd25eb7fb008b724d932df2a6d2ed8e03c4ea069..0000000000000000000000000000000000000000 --- a/arkui-plugins/test/demo/mock/decorators/storageprop/storageprop-appstorage.ets +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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 { Component, Entry, Column, Text, ClickEvent } from "@ohos.arkui.component" -import { StorageProp, AppStorage } from "@ohos.arkui.stateManagement" - -class Data { - code: number; - - constructor(code: number) { - this.code = code; - } -} - -AppStorage.setOrCreate('PropA', 47); -AppStorage.setOrCreate('PropB', new Data(50)); - -@Entry -@Component -struct Index { - @StorageProp('PropA') storageProp: number = 1; - @StorageProp('PropB') storagePropObject: Data = new Data(1); - - build() { - Column() { - Text(`From AppStorage ${this.storageProp}`) - .onClick((e: ClickEvent) => { - this.storageProp += 1; - }) - - Text(`From AppStorage ${this.storagePropObject.code}`) - .onClick((e: ClickEvent) => { - this.storagePropObject.code += 1; - }) - } - } -} diff --git a/arkui-plugins/test/demo/mock/decorators/storageprop/storageprop-complex-type.ets b/arkui-plugins/test/demo/mock/decorators/storageprop/storageprop-complex-type.ets deleted file mode 100644 index 50c2ea128a534ea463a12c780b1fa27ab051fe10..0000000000000000000000000000000000000000 --- a/arkui-plugins/test/demo/mock/decorators/storageprop/storageprop-complex-type.ets +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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 { Component, Entry } from "@ohos.arkui.component" // TextAttribute should be insert by ui-plugins -import { StorageProp } from "@ohos.arkui.stateManagement" - -class Person{ - name: string = '' - constructor(name: string){} -} - -enum Status { - Success = 200, - NotFound = 404, - ServerError = 500 -} - -@Entry -@Component -struct MyStateSample { - @StorageProp('Prop1') arrayB: number[] = [1,2,3]; - @StorageProp('Prop2') objectB: Object = {}; - @StorageProp('Prop3') dateB: Date = new Date('2021-09-09'); - @StorageProp('Prop4') setB: Set = new Set(); - @StorageProp('Prop5') mapB: Map = new Map(); - @StorageProp('Prop7') classB: Person = new Person("Kevin"); - @StorageProp('Prop8') enumB: Status = Status.NotFound; - - build() {} -} \ No newline at end of file diff --git a/arkui-plugins/test/demo/mock/decorators/storageprop/storageprop-primitive-type.ets b/arkui-plugins/test/demo/mock/decorators/storageprop/storageprop-primitive-type.ets deleted file mode 100644 index 95d4ed58d42aaa7f76fbdfe8b1c6798ac2e22b6f..0000000000000000000000000000000000000000 --- a/arkui-plugins/test/demo/mock/decorators/storageprop/storageprop-primitive-type.ets +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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 { Component, Entry } from "@ohos.arkui.component" // TextAttribute should be insert by ui-plugins -import { StorageProp } from "@ohos.arkui.stateManagement" - -@Entry -@Component -struct MyStateSample { - @StorageProp('Prop1') numB: number = 43; - @StorageProp('Prop2') stringB: string = 'BB'; - @StorageProp('Prop3') booleanB: boolean = false; - - build() {} -} \ No newline at end of file diff --git a/arkui-plugins/test/demo/mock/decorators/watch/watch-basic.ets b/arkui-plugins/test/demo/mock/decorators/watch/watch-basic.ets index 4c36212e7da874ab1268d3e671f7f6d69c867ee3..8fb667a2f32689110cb08d7f8a85cf665ae16c22 100644 --- a/arkui-plugins/test/demo/mock/decorators/watch/watch-basic.ets +++ b/arkui-plugins/test/demo/mock/decorators/watch/watch-basic.ets @@ -14,7 +14,7 @@ */ import { Component, Entry, Column } from "@ohos.arkui.component" -import { State, Prop, StorageLink, StorageProp, Link, Watch, ObjectLink, Observed, Track, Provide, Consume } from "@ohos.arkui.stateManagement" +import { State, PropRef, StorageLink, StoragePropRef, Link, Watch, ObjectLink, Observed, Track, Provide, Consume } from "@ohos.arkui.stateManagement" @Observed class A { @@ -26,10 +26,10 @@ class A { @Component struct MyStateSample { @State @Watch('stateOnChange') statevar: string = 'Hello World'; - @Prop @Watch('propOnChange') propvar: string = 'Hello World'; + @PropRef @Watch('propOnChange') propvar: string = 'Hello World'; @Link @Watch('linkOnChange') linkvar: string; @StorageLink('prop1') @Watch('storageLinkOnChange') storagelinkvar: string = 'Hello World'; - @StorageProp('prop2') @Watch('storagePropOnChange') storagepropvar: string = 'Hello World'; + @StoragePropRef('prop2') @Watch('storagePropOnChange') storagepropvar: string = 'Hello World'; @ObjectLink @Watch('objectLinkOnChange') objectlinkvar: A; @Provide @Watch('ProvideOnChange') providevar: string = 'Hello World'; diff --git a/arkui-plugins/test/demo/mock/imports/kit-import.ets b/arkui-plugins/test/demo/mock/imports/kit-import.ets index 5cd7771b28e08fdfdd73c40373362704b6f01bd6..37f13222ddab5a5bbfa5dddc9e4755cce678332e 100644 --- a/arkui-plugins/test/demo/mock/imports/kit-import.ets +++ b/arkui-plugins/test/demo/mock/imports/kit-import.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -import { Prop, Column, Entry } from "@kit.ArkUI"; +import { PropRef, Column, Entry } from "@kit.ArkUI"; import { Text, Component, ClickEvent } from "@ohos.arkui.component"; import { State } from "@ohos.arkui.stateManagement"; import { Button } from "arkui.component.button"; @@ -23,7 +23,7 @@ import hilog from "@ohos.hilog"; @Component struct A { @State a: string = "str"; - @Prop b: string; + @PropRef b: string; build() { Column() { diff --git a/arkui-plugins/test/ut/ui-plugins/builder-lambda/condition-scope/block-in-switch-case.test.ts b/arkui-plugins/test/ut/ui-plugins/builder-lambda/condition-scope/block-in-switch-case.test.ts index b38eeb4a638446262bd99177d5bb1f613e2ffdf7..f7c6d9d5a8ac83ab4da87e895bf0b2dbfa4842fa 100644 --- a/arkui-plugins/test/ut/ui-plugins/builder-lambda/condition-scope/block-in-switch-case.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/builder-lambda/condition-scope/block-in-switch-case.test.ts @@ -175,6 +175,9 @@ function main() {} set num(num: (int | undefined)) get num(): (int | undefined) + set __options_has_num(__options_has_num: (boolean | undefined)) + + get __options_has_num(): (boolean | undefined) } `; @@ -484,6 +487,9 @@ function main() {} set num(num: (int | undefined)) get num(): (int | undefined) + set __options_has_num(__options_has_num: (boolean | undefined)) + + get __options_has_num(): (boolean | undefined) } `; diff --git a/arkui-plugins/test/ut/ui-plugins/builder-lambda/condition-scope/if-in-switch-in-content.test.ts b/arkui-plugins/test/ut/ui-plugins/builder-lambda/condition-scope/if-in-switch-in-content.test.ts index 66e215a5bef36835251384610f34520d0375e52f..3aa96d984e04a1668997e39cb03fcb25b903ac2b 100644 --- a/arkui-plugins/test/ut/ui-plugins/builder-lambda/condition-scope/if-in-switch-in-content.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/builder-lambda/condition-scope/if-in-switch-in-content.test.ts @@ -103,8 +103,13 @@ function main() {} public constructor() {} } @Component() export interface __Options_IfInSwitch { - set num(num: (string | undefined)) - get num(): (string | undefined) + set num(num: (string | undefined)) + + get num(): (string | undefined) + set __options_has_num(__options_has_num: (boolean | undefined)) + + get __options_has_num(): (boolean | undefined) + } `; @@ -277,8 +282,13 @@ function main() {} public constructor() {} } @Component() export interface __Options_IfInSwitch { - set num(num: (string | undefined)) - get num(): (string | undefined) + set num(num: (string | undefined)) + + get num(): (string | undefined) + set __options_has_num(__options_has_num: (boolean | undefined)) + + get __options_has_num(): (boolean | undefined) + } `; diff --git a/arkui-plugins/test/ut/ui-plugins/builder-lambda/condition-scope/non-builder-within-builder.test.ts b/arkui-plugins/test/ut/ui-plugins/builder-lambda/condition-scope/non-builder-within-builder.test.ts index 7bfebe64eb48474a8c925462a3d4fbce25ef49a7..c49b315e04ebd69dbf612063812dcaa4f6b0710d 100644 --- a/arkui-plugins/test/ut/ui-plugins/builder-lambda/condition-scope/non-builder-within-builder.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/builder-lambda/condition-scope/non-builder-within-builder.test.ts @@ -41,11 +41,12 @@ const parsedTransform: Plugins = { }; const expectedUIScript: string = ` +import { MemoSkip as MemoSkip } from "arkui.stateManagement.runtime"; import { memo as memo } from \"arkui.stateManagement.runtime\"; import { CustomComponent as CustomComponent } from \"arkui.component.customComponent\"; import { Component as Component, Builder as Builder } from \"@ohos.arkui.component\"; function main() {} -@memo() function TestComponent(init: TestInitCallback, update: TestUpdateCallback): void {} +@memo() function TestComponent(@MemoSkip() init: TestInitCallback, @MemoSkip() update: TestUpdateCallback): void {} type TestInitCallback = (()=> void); type TestUpdateCallback = (()=> void); @Component() final struct MyStateSample extends CustomComponent { diff --git a/arkui-plugins/test/ut/ui-plugins/builder-lambda/condition-scope/switch-case-in-content.test.ts b/arkui-plugins/test/ut/ui-plugins/builder-lambda/condition-scope/switch-case-in-content.test.ts index 5f4ac9e902691275846c4543a14157d43945220e..53004cc90f6799d456c16c32f65c1f4fd9392a36 100644 --- a/arkui-plugins/test/ut/ui-plugins/builder-lambda/condition-scope/switch-case-in-content.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/builder-lambda/condition-scope/switch-case-in-content.test.ts @@ -93,8 +93,13 @@ function main() {} public constructor() {} } @Component() export interface __Options_SwitchCase { - set num(num: (string | undefined)) - get num(): (string | undefined) + set num(num: (string | undefined)) + + get num(): (string | undefined) + set __options_has_num(__options_has_num: (boolean | undefined)) + + get __options_has_num(): (boolean | undefined) + } `; @@ -222,8 +227,13 @@ function main() {} public constructor() {} } @Component() export interface __Options_SwitchCase { - set num(num: (string | undefined)) - get num(): (string | undefined) + set num(num: (string | undefined)) + + get num(): (string | undefined) + set __options_has_num(__options_has_num: (boolean | undefined)) + + get __options_has_num(): (boolean | undefined) + } `; diff --git a/arkui-plugins/test/ut/ui-plugins/builder-lambda/condition-scope/switch-in-if-in-content.test.ts b/arkui-plugins/test/ut/ui-plugins/builder-lambda/condition-scope/switch-in-if-in-content.test.ts index 588d255e396f05f1d65c4915417cb4a39ed6069c..fe6cc8a3a551887072890742a3b9cce5c54bb6ac 100644 --- a/arkui-plugins/test/ut/ui-plugins/builder-lambda/condition-scope/switch-in-if-in-content.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/builder-lambda/condition-scope/switch-in-if-in-content.test.ts @@ -79,8 +79,13 @@ function main() {} public constructor() {} } @Component() export interface __Options_SwitchInIf { - set num(num: (string | undefined)) - get num(): (string | undefined) + set num(num: (string | undefined)) + + get num(): (string | undefined) + set __options_has_num(__options_has_num: (boolean | undefined)) + + get __options_has_num(): (boolean | undefined) + } `; @@ -185,8 +190,13 @@ function main() {} public constructor() {} } @Component() export interface __Options_SwitchInIf { - set num(num: (string | undefined)) - get num(): (string | undefined) + set num(num: (string | undefined)) + + get num(): (string | undefined) + set __options_has_num(__options_has_num: (boolean | undefined)) + + get __options_has_num(): (boolean | undefined) + } `; diff --git a/arkui-plugins/test/ut/ui-plugins/builder-lambda/condition-scope/with-builder.test.ts b/arkui-plugins/test/ut/ui-plugins/builder-lambda/condition-scope/with-builder.test.ts index 570c82a4beff068515ed2a9d92023d629f521632..b7eb599fe0784901cacdeae60cc3c6004d300b97 100644 --- a/arkui-plugins/test/ut/ui-plugins/builder-lambda/condition-scope/with-builder.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/builder-lambda/condition-scope/with-builder.test.ts @@ -66,7 +66,6 @@ function main() {} }) as (()=> void))); param(); } -wBuilder = wrapBuilder(ParamBuilder); @Component() final struct MyStruct extends CustomComponent { public __initializeStruct(initializers: (__Options_MyStruct | undefined), @memo() content: ((()=> void) | undefined)): void {} public __updateStruct(initializers: (__Options_MyStruct | undefined)): void {} @@ -103,6 +102,7 @@ wBuilder = wrapBuilder(ParamBuilder); })); this.myBuilderMethod(); }), + __options_has_myBuilderParam: true, }, undefined, undefined); })); } @@ -143,8 +143,10 @@ wBuilder = wrapBuilder(ParamBuilder); @Component() export interface __Options_MyStruct { } @Component() export interface __Options_Child { - set myBuilderParam(myBuilderParam: (@memo() (()=> void) | undefined)) - get myBuilderParam(): (@memo() (()=> void) | undefined) + set myBuilderParam(myBuilderParam: (@memo() (()=> void) | undefined)) + get myBuilderParam(): (@memo() (()=> void) | undefined) + set __options_has_myBuilderParam(__options_has_myBuilderParam: (boolean | undefined)) + get __options_has_myBuilderParam(): (boolean | undefined) } `; @@ -246,7 +248,6 @@ function main() {} return; } } -wBuilder = wrapBuilder(ParamBuilder); @Component() final struct MyStruct extends CustomComponent { public __initializeStruct(initializers: (__Options_MyStruct | undefined), @memo() content: (((__memo_context: __memo_context_type, __memo_id: __memo_id_type)=> void) | undefined)): void {} public __updateStruct(initializers: (__Options_MyStruct | undefined)): void {} @@ -374,6 +375,7 @@ wBuilder = wrapBuilder(ParamBuilder); return; } }), + __options_has_myBuilderParam: true, }, undefined, undefined); { __memo_scope.recache(); @@ -476,8 +478,10 @@ wBuilder = wrapBuilder(ParamBuilder); @Component() export interface __Options_MyStruct { } @Component() export interface __Options_Child { - set myBuilderParam(myBuilderParam: (@memo() ((__memo_context: __memo_context_type, __memo_id: __memo_id_type)=> void) | undefined)) - get myBuilderParam(): (@memo() ((__memo_context: __memo_context_type, __memo_id: __memo_id_type)=> void) | undefined) + set myBuilderParam(myBuilderParam: (@memo() ((__memo_context: __memo_context_type, __memo_id: __memo_id_type)=> void) | undefined)) + get myBuilderParam(): (@memo() ((__memo_context: __memo_context_type, __memo_id: __memo_id_type)=> void) | undefined) + set __options_has_myBuilderParam(__options_has_myBuilderParam: (boolean | undefined)) + get __options_has_myBuilderParam(): (boolean | undefined) } `; diff --git a/arkui-plugins/test/ut/ui-plugins/builder-lambda/custom-component/custom-component-call.test.ts b/arkui-plugins/test/ut/ui-plugins/builder-lambda/custom-component/custom-component-call.test.ts index 3215144c70cbcc6cc9e953ae3c8b4c42167c26c5..825333cb385de7fcf0c8e61954bcef463c89c5b8 100644 --- a/arkui-plugins/test/ut/ui-plugins/builder-lambda/custom-component/custom-component-call.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/builder-lambda/custom-component/custom-component-call.test.ts @@ -84,6 +84,7 @@ import { Text as Text, Column as Column, Component as Component, Builder as Buil @Component() export interface __Options_CustomContainer { @BuilderParam() closer?: (()=> void); + __options_has_closer?: boolean; } @@ -171,6 +172,9 @@ function main() {} set closer(closer: (@memo() (()=> void) | undefined)) get closer(): (@memo() (()=> void) | undefined) + set __options_has_closer(__options_has_closer: (boolean | undefined)) + + get __options_has_closer(): (boolean | undefined) } diff --git a/arkui-plugins/test/ut/ui-plugins/component/declare-component.test.ts b/arkui-plugins/test/ut/ui-plugins/component/declare-component.test.ts index 6261ad5d528fcbf90be7e222a349ac309d78c360..5b2025b8cab9bb947ee755bb775d851c88a38c1b 100644 --- a/arkui-plugins/test/ut/ui-plugins/component/declare-component.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/component/declare-component.test.ts @@ -42,12 +42,12 @@ import { CustomComponent as CustomComponent } from "arkui.component.customCompon import { Component as Component, ResourceStr as ResourceStr, Builder as Builder } from "@ohos.arkui.component"; -import { Prop as Prop, State as State } from "@ohos.arkui.stateManagement"; +import { PropRef as PropRef, State as State } from "@ohos.arkui.stateManagement"; @Component() export declare final struct SwipeRefresher extends CustomComponent { - @Prop() public content?: (ResourceStr | undefined); + @PropRef() public content?: (ResourceStr | undefined); - @Prop() public isLoading: boolean; + @PropRef() public isLoading: boolean; @State() public code: number; @@ -61,11 +61,14 @@ import { Prop as Prop, State as State } from "@ohos.arkui.stateManagement"; @Component() export declare interface __Options_SwipeRefresher { content?: (ResourceStr | undefined); - @Prop() __backing_content?: (ResourceStr | undefined); + @PropRef() __backing_content?: (ResourceStr | undefined); + __options_has_content?: boolean; isLoading?: boolean; - @Prop() __backing_isLoading?: boolean; + @PropRef() __backing_isLoading?: boolean; + __options_has_isLoading?: boolean; code?: number; @State() __backing_code?: number; + __options_has_code?: boolean; } `; @@ -77,7 +80,7 @@ function testParsedTransformer(this: PluginTestContext): void { const expectedCheckedScript: string = ` import { IStateDecoratedVariable as IStateDecoratedVariable } from "arkui.stateManagement.decorator"; -import { IPropDecoratedVariable as IPropDecoratedVariable } from "arkui.stateManagement.decorator"; +import { IPropRefDecoratedVariable as IPropRefDecoratedVariable } from "arkui.stateManagement.decorator"; import { memo as memo } from "arkui.stateManagement.runtime"; @@ -85,14 +88,14 @@ import { CustomComponent as CustomComponent } from "arkui.component.customCompon import { Component as Component, ResourceStr as ResourceStr, Builder as Builder } from "@ohos.arkui.component"; -import { Prop as Prop, State as State } from "@ohos.arkui.stateManagement"; +import { PropRef as PropRef, State as State } from "@ohos.arkui.stateManagement"; function main() {} @Component() export declare final struct SwipeRefresher extends CustomComponent { - @Prop() public content?: (ResourceStr | undefined); + @PropRef() public content?: (ResourceStr | undefined); - @Prop() public isLoading: boolean; + @PropRef() public isLoading: boolean; @State() public code: number; @@ -108,21 +111,30 @@ function main() {} set content(content: ((ResourceStr | undefined) | undefined)) get content(): ((ResourceStr | undefined) | undefined) - set __backing_content(__backing_content: (IPropDecoratedVariable<(ResourceStr | undefined)> | undefined)) + set __backing_content(__backing_content: (IPropRefDecoratedVariable<(ResourceStr | undefined)> | undefined)) - get __backing_content(): (IPropDecoratedVariable<(ResourceStr | undefined)> | undefined) + get __backing_content(): (IPropRefDecoratedVariable<(ResourceStr | undefined)> | undefined) + set __options_has_content(__options_has_content: (boolean | undefined)) + + get __options_has_content(): (boolean | undefined) set isLoading(isLoading: (boolean | undefined)) get isLoading(): (boolean | undefined) - set __backing_isLoading(__backing_isLoading: (IPropDecoratedVariable | undefined)) + set __backing_isLoading(__backing_isLoading: (IPropRefDecoratedVariable | undefined)) + + get __backing_isLoading(): (IPropRefDecoratedVariable | undefined) + set __options_has_isLoading(__options_has_isLoading: (boolean | undefined)) - get __backing_isLoading(): (IPropDecoratedVariable | undefined) + get __options_has_isLoading(): (boolean | undefined) set code(code: (number | undefined)) get code(): (number | undefined) set __backing_code(__backing_code: (IStateDecoratedVariable | undefined)) get __backing_code(): (IStateDecoratedVariable | undefined) + set __options_has_code(__options_has_code: (boolean | undefined)) + + get __options_has_code(): (boolean | undefined) } `; diff --git a/arkui-plugins/test/ut/ui-plugins/component/for-each.test.ts b/arkui-plugins/test/ut/ui-plugins/component/for-each.test.ts index 52e9fd7b7c49db71da2ee588630d54098c043c69..3523ffc39fdf6a40442675e6d90a9d309b53bf75 100644 --- a/arkui-plugins/test/ut/ui-plugins/component/for-each.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/component/for-each.test.ts @@ -136,6 +136,9 @@ class AB { set arr(arr: (Array | undefined)) get arr(): (Array | undefined) + set __options_has_arr(__options_has_arr: (boolean | undefined)) + + get __options_has_arr(): (boolean | undefined) } `; diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/builder-param/builder-param-passing.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/builder-param/builder-param-passing.test.ts index 26590b874bc38d4685df10a36b88ed812dba11b9..ec5fad9a3d6af3087369039659eb586efa2363ac 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/builder-param/builder-param-passing.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/builder-param/builder-param-passing.test.ts @@ -89,6 +89,7 @@ function main() {} return new Child(); }), { customBuilderParam: this.componentBuilder, + __options_has_customBuilderParam: true, }, undefined, undefined); Child._instantiateImpl(undefined, (() => { return new Child(); @@ -96,6 +97,7 @@ function main() {} customBuilderParam: @memo() (() => { this.componentBuilder(); }), + __options_has_customBuilderParam: true, }, undefined, undefined); Child._instantiateImpl(undefined, (() => { return new Child(); @@ -113,6 +115,9 @@ function main() {} set customBuilderParam(customBuilderParam: (@memo() (()=> void) | undefined)) get customBuilderParam(): (@memo() (()=> void) | undefined) + set __options_has_customBuilderParam(__options_has_customBuilderParam: (boolean | undefined)) + + get __options_has_customBuilderParam(): (boolean | undefined) } @@ -210,6 +215,7 @@ function main() {} return new Child(); }), { customBuilderParam: this.componentBuilder, + __options_has_customBuilderParam: true, }, undefined, undefined); Child._instantiateImpl(__memo_context, ((__memo_id) + (218979098)), undefined, (() => { return new Child(); @@ -226,6 +232,7 @@ function main() {} return; } }), + __options_has_customBuilderParam: true, }, undefined, undefined); Child._instantiateImpl(__memo_context, ((__memo_id) + (213687742)), undefined, (() => { return new Child(); @@ -260,6 +267,9 @@ function main() {} set customBuilderParam(customBuilderParam: (@memo() ((__memo_context: __memo_context_type, __memo_id: __memo_id_type)=> void) | undefined)) get customBuilderParam(): (@memo() ((__memo_context: __memo_context_type, __memo_id: __memo_id_type)=> void) | undefined) + set __options_has_customBuilderParam(__options_has_customBuilderParam: (boolean | undefined)) + + get __options_has_customBuilderParam(): (boolean | undefined) } diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/builder-param/init-with-local-builder.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/builder-param/init-with-local-builder.test.ts index b480c115489bc4484e8a36e36d7fe1b9d98ef800..167df0b606a57019d64eb30cb71224d29990017d 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/builder-param/init-with-local-builder.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/builder-param/init-with-local-builder.test.ts @@ -90,9 +90,15 @@ function main() {} set customBuilderParam(customBuilderParam: (@memo() (()=> void) | undefined)) get customBuilderParam(): (@memo() (()=> void) | undefined) + set __options_has_customBuilderParam(__options_has_customBuilderParam: (boolean | undefined)) + + get __options_has_customBuilderParam(): (boolean | undefined) set customBuilderParam2(customBuilderParam2: (@memo() ((str: string)=> void) | undefined)) get customBuilderParam2(): (@memo() ((str: string)=> void) | undefined) + set __options_has_customBuilderParam2(__options_has_customBuilderParam2: (boolean | undefined)) + + get __options_has_customBuilderParam2(): (boolean | undefined) } `; @@ -182,9 +188,15 @@ function main() {} set customBuilderParam(customBuilderParam: (@memo() ((__memo_context: __memo_context_type, __memo_id: __memo_id_type)=> void) | undefined)) get customBuilderParam(): (@memo() ((__memo_context: __memo_context_type, __memo_id: __memo_id_type)=> void) | undefined) + set __options_has_customBuilderParam(__options_has_customBuilderParam: (boolean | undefined)) + + get __options_has_customBuilderParam(): (boolean | undefined) set customBuilderParam2(customBuilderParam2: (@memo() ((__memo_context: __memo_context_type, __memo_id: __memo_id_type, str: string)=> void) | undefined)) get customBuilderParam2(): (@memo() ((__memo_context: __memo_context_type, __memo_id: __memo_id_type, str: string)=> void) | undefined) + set __options_has_customBuilderParam2(__options_has_customBuilderParam2: (boolean | undefined)) + + get __options_has_customBuilderParam2(): (boolean | undefined) } `; diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/builder-param/optional-builder-param.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/builder-param/optional-builder-param.test.ts index 68b761ca7ba361ab6ed07f910ee8aed00ad5b032..bc43a4482bdf7980a2a94435e6250c1d10409379 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/builder-param/optional-builder-param.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/builder-param/optional-builder-param.test.ts @@ -121,6 +121,7 @@ function main() {} customBuilderParam2: @memo() (() => { this.componentBuilder(); }), + __options_has_customBuilderParam2: true, }, undefined, undefined); })); } @@ -133,9 +134,15 @@ function main() {} set customBuilderParam2(customBuilderParam2: (((()=> void) | undefined) | undefined)) get customBuilderParam2(): (((()=> void) | undefined) | undefined) + set __options_has_customBuilderParam2(__options_has_customBuilderParam2: (boolean | undefined)) + + get __options_has_customBuilderParam2(): (boolean | undefined) set customBuilderParam1(customBuilderParam1: (@memo() (()=> void) | undefined)) get customBuilderParam1(): (@memo() (()=> void) | undefined) + set __options_has_customBuilderParam1(__options_has_customBuilderParam1: (boolean | undefined)) + + get __options_has_customBuilderParam1(): (boolean | undefined) } @@ -320,6 +327,7 @@ function main() {} return; } }), + __options_has_customBuilderParam2: true, }, undefined, undefined); { __memo_scope.recache(); @@ -340,9 +348,15 @@ function main() {} set customBuilderParam2(customBuilderParam2: ((((__memo_context: __memo_context_type, __memo_id: __memo_id_type)=> void) | undefined) | undefined)) get customBuilderParam2(): ((((__memo_context: __memo_context_type, __memo_id: __memo_id_type)=> void) | undefined) | undefined) + set __options_has_customBuilderParam2(__options_has_customBuilderParam2: (boolean | undefined)) + + get __options_has_customBuilderParam2(): (boolean | undefined) set customBuilderParam1(customBuilderParam1: (@memo() ((__memo_context: __memo_context_type, __memo_id: __memo_id_type)=> void) | undefined)) get customBuilderParam1(): (@memo() ((__memo_context: __memo_context_type, __memo_id: __memo_id_type)=> void) | undefined) + set __options_has_customBuilderParam1(__options_has_customBuilderParam1: (boolean | undefined)) + + get __options_has_customBuilderParam1(): (boolean | undefined) } diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/computed/computed-in-struct.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/computed/computed-in-struct.test.ts index e904a0ed431c395c412c7807f1184501ee2d0ff6..9b0358df96a8c32a2cd9fd3e844ac1cfbed839d3 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/computed/computed-in-struct.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/computed/computed-in-struct.test.ts @@ -54,6 +54,7 @@ import { Computed as Computed, Local as Local } from "@ohos.arkui.stateManagemen function main() {} + @ComponentV2() final struct Index extends CustomComponentV2 { public __initializeStruct(initializers: (__Options_Index | undefined), @memo() content: ((()=> void) | undefined)): void { this.__backing_firstName = STATE_MGMT_FACTORY.makeLocal(this, "firstName", "Li"); @@ -136,15 +137,24 @@ function main() {} set __backing_firstName(__backing_firstName: (ILocalDecoratedVariable | undefined)) get __backing_firstName(): (ILocalDecoratedVariable | undefined) + set __options_has_firstName(__options_has_firstName: (boolean | undefined)) + + get __options_has_firstName(): (boolean | undefined) set lastName(lastName: (string | undefined)) get lastName(): (string | undefined) set __backing_lastName(__backing_lastName: (ILocalDecoratedVariable | undefined)) get __backing_lastName(): (ILocalDecoratedVariable | undefined) + set __options_has_lastName(__options_has_lastName: (boolean | undefined)) + + get __options_has_lastName(): (boolean | undefined) set age(age: (number | undefined)) get age(): (number | undefined) + set __options_has_age(__options_has_age: (boolean | undefined)) + + get __options_has_age(): (boolean | undefined) } `; diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/computed/computed-no-return-type.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/computed/computed-no-return-type.test.ts index c592e5333227dab8155878136c325b9113c8a18e..b94bdc28bc3b6bbdb01191e18e09594fe1af01c2 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/computed/computed-no-return-type.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/computed/computed-no-return-type.test.ts @@ -67,7 +67,6 @@ import { Computed as Computed, Local as Local } from "@ohos.arkui.stateManagemen function main() {} - @ObservedV2() class Name implements IObservedObject, ISubscribedWatches { @JSONStringifyIgnore() private subscribedWatches: ISubscribedWatches = STATE_MGMT_FACTORY.makeSubscribedWatches(); @@ -212,15 +211,24 @@ function main() {} set __backing_firstName(__backing_firstName: (ILocalDecoratedVariable | undefined)) get __backing_firstName(): (ILocalDecoratedVariable | undefined) + set __options_has_firstName(__options_has_firstName: (boolean | undefined)) + + get __options_has_firstName(): (boolean | undefined) set lastName(lastName: (string | undefined)) get lastName(): (string | undefined) set __backing_lastName(__backing_lastName: (ILocalDecoratedVariable | undefined)) get __backing_lastName(): (ILocalDecoratedVariable | undefined) + set __options_has_lastName(__options_has_lastName: (boolean | undefined)) + + get __options_has_lastName(): (boolean | undefined) set age(age: (number | undefined)) get age(): (number | undefined) + set __options_has_age(__options_has_age: (boolean | undefined)) + + get __options_has_age(): (boolean | undefined) } `; diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/computed/static-computed.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/computed/static-computed.test.ts index 2d7331ed63ae4cd279816b51c602f0c4a61d31eb..7a3eda3bd626846ff46a58fd08ac16acb1c11cb2 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/computed/static-computed.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/computed/static-computed.test.ts @@ -64,6 +64,7 @@ import { Computed as Computed, ObservedV2 as ObservedV2, Trace as Trace, Local a function main() {} + @ObservedV2() class Name implements IObservedObject, ISubscribedWatches { @JSONStringifyIgnore() private subscribedWatches: ISubscribedWatches = STATE_MGMT_FACTORY.makeSubscribedWatches(); @@ -247,12 +248,18 @@ function main() {} set __backing_localVar1(__backing_localVar1: (ILocalDecoratedVariable | undefined)) get __backing_localVar1(): (ILocalDecoratedVariable | undefined) + set __options_has_localVar1(__options_has_localVar1: (boolean | undefined)) + + get __options_has_localVar1(): (boolean | undefined) set localVar2(localVar2: (number | undefined)) get localVar2(): (number | undefined) set __backing_localVar2(__backing_localVar2: (ILocalDecoratedVariable | undefined)) get __backing_localVar2(): (ILocalDecoratedVariable | undefined) + set __options_has_localVar2(__options_has_localVar2: (boolean | undefined)) + + get __options_has_localVar2(): (boolean | undefined) } diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/custom-dialog/base-custom-dialog.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/custom-dialog/base-custom-dialog.test.ts index 0e22b1f8c853bbd17a5979b0ad19306cb3c52ba2..f735b8526465edb6a380d72feb2b5c9814bb0baa 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/custom-dialog/base-custom-dialog.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/custom-dialog/base-custom-dialog.test.ts @@ -169,9 +169,11 @@ function main() {} cancel: (() => { this.onCancel(); }), + __options_has_cancel: true, confirm: (() => { this.onAccept(); }), + __options_has_confirm: true, }, undefined); }), cancel: this.existApp, @@ -241,24 +243,39 @@ function main() {} set aaController(aaController: ((CustomDialogController | undefined) | undefined)) get aaController(): ((CustomDialogController | undefined) | undefined) + set __options_has_aaController(__options_has_aaController: (boolean | undefined)) + + get __options_has_aaController(): (boolean | undefined) set text(text: (string | undefined)) get text(): (string | undefined) set __backing_text(__backing_text: (IStateDecoratedVariable | undefined)) get __backing_text(): (IStateDecoratedVariable | undefined) + set __options_has_text(__options_has_text: (boolean | undefined)) + + get __options_has_text(): (boolean | undefined) set cancel(cancel: ((()=> void) | undefined)) get cancel(): ((()=> void) | undefined) + set __options_has_cancel(__options_has_cancel: (boolean | undefined)) + + get __options_has_cancel(): (boolean | undefined) set confirm(confirm: ((()=> void) | undefined)) get confirm(): ((()=> void) | undefined) + set __options_has_confirm(__options_has_confirm: (boolean | undefined)) + + get __options_has_confirm(): (boolean | undefined) set hh(hh: (string | undefined)) get hh(): (string | undefined) set __backing_hh(__backing_hh: (IStateDecoratedVariable | undefined)) get __backing_hh(): (IStateDecoratedVariable | undefined) + set __options_has_hh(__options_has_hh: (boolean | undefined)) + + get __options_has_hh(): (boolean | undefined) } @@ -266,6 +283,9 @@ function main() {} set dialogController(dialogController: ((CustomDialogController | null) | undefined)) get dialogController(): ((CustomDialogController | null) | undefined) + set __options_has_dialogController(__options_has_dialogController: (boolean | undefined)) + + get __options_has_dialogController(): (boolean | undefined) } `; diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/custom-dialog/builder-dialog-options.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/custom-dialog/builder-dialog-options.test.ts index 0d02a2478390192674a6beecf21db972795a4f56..9d59803b45280bd118de24238b34ac40ef75d7b4 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/custom-dialog/builder-dialog-options.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/custom-dialog/builder-dialog-options.test.ts @@ -80,11 +80,13 @@ import hilog from "@ohos.hilog"; @Component() export interface __Options_CustomDialogUser { dialogController?: (CustomDialogController | null); + __options_has_dialogController?: boolean; } @Component() export interface __Options_CustomDialogUser2 { dialogController?: (CustomDialogController | null); + __options_has_dialogController?: boolean; } `; @@ -174,6 +176,9 @@ function main() {} set dialogController(dialogController: ((CustomDialogController | null) | undefined)) get dialogController(): ((CustomDialogController | null) | undefined) + set __options_has_dialogController(__options_has_dialogController: (boolean | undefined)) + + get __options_has_dialogController(): (boolean | undefined) } @@ -181,6 +186,9 @@ function main() {} set dialogController(dialogController: ((CustomDialogController | null) | undefined)) get dialogController(): ((CustomDialogController | null) | undefined) + set __options_has_dialogController(__options_has_dialogController: (boolean | undefined)) + + get __options_has_dialogController(): (boolean | undefined) } `; diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/custom-dialog/controller-in-build.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/custom-dialog/controller-in-build.test.ts index ecad395ed4a54f40e9f52a70b7424daf6011c66d..dc34111c0abe8a86c37ee3f00d5d081fa54211c1 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/custom-dialog/controller-in-build.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/custom-dialog/controller-in-build.test.ts @@ -52,7 +52,7 @@ import { CustomComponent as CustomComponent } from "arkui.component.customCompon import { Text as Text, Column as Column, Component as Component, Button as Button, ClickEvent as ClickEvent } from "@ohos.arkui.component"; -import { State as State, Link as Link, Prop as Prop } from "@ohos.arkui.stateManagement"; +import { State as State } from "@ohos.arkui.stateManagement"; import { CustomDialog as CustomDialog, CustomDialogController as CustomDialogController, CustomDialogControllerOptions as CustomDialogControllerOptions } from "@kit.ArkUI"; @@ -60,8 +60,6 @@ import hilog from "@ohos.hilog"; function main() {} - - @CustomDialog() final struct CustomDialogExample extends BaseCustomDialog { public __initializeStruct(initializers: (__Options_CustomDialogExample | undefined), @memo() content: ((()=> void) | undefined)): void { if (({let gensym___45519047 = initializers; @@ -134,7 +132,7 @@ function main() {} builder: @memo() (() => { CustomDialogExample._instantiateImpl(undefined, (() => { const instance = new CustomDialogExample(); - instance.__setDialogController__((gensym___220374545 as CustomDialogController)); + instance.__setDialogController__((gensym___90667230 as CustomDialogController)); return instance; }), {}, undefined); }), @@ -155,18 +153,27 @@ function main() {} set aaController(aaController: ((CustomDialogController | undefined) | undefined)) get aaController(): ((CustomDialogController | undefined) | undefined) + set __options_has_aaController(__options_has_aaController: (boolean | undefined)) + + get __options_has_aaController(): (boolean | undefined) set text(text: (string | undefined)) get text(): (string | undefined) set __backing_text(__backing_text: (IStateDecoratedVariable | undefined)) get __backing_text(): (IStateDecoratedVariable | undefined) + set __options_has_text(__options_has_text: (boolean | undefined)) + + get __options_has_text(): (boolean | undefined) set hh(hh: (string | undefined)) get hh(): (string | undefined) set __backing_hh(__backing_hh: (IStateDecoratedVariable | undefined)) get __backing_hh(): (IStateDecoratedVariable | undefined) + set __options_has_hh(__options_has_hh: (boolean | undefined)) + + get __options_has_hh(): (boolean | undefined) } diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/custom-dialog/controller-in-method.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/custom-dialog/controller-in-method.test.ts index a5ae0dbe294e454667ac3292a52fead27a1171a0..1da0f6f11eeff2ef2f31856b5a660bda3d2965a9 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/custom-dialog/controller-in-method.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/custom-dialog/controller-in-method.test.ts @@ -42,7 +42,6 @@ import { memo as memo } from "arkui.stateManagement.runtime"; import { BaseCustomDialog as BaseCustomDialog } from "arkui.component.customComponent"; import { CustomComponent as CustomComponent } from "arkui.component.customComponent"; import { Component as Component, CustomDialog as CustomDialog, CustomDialogController as CustomDialogController } from "@ohos.arkui.component"; -import hilog from "@ohos.hilog"; function main() {} @@ -70,7 +69,7 @@ function main() {} @memo() public build() {} public constructor() {} - + public __setDialogController__(controller: CustomDialogController): void { this.__backing_aaController = controller; } @@ -148,6 +147,9 @@ function main() {} set aaController(aaController: ((CustomDialogController | undefined) | undefined)) get aaController(): ((CustomDialogController | undefined) | undefined) + set __options_has_aaController(__options_has_aaController: (boolean | undefined)) + + get __options_has_aaController(): (boolean | undefined) } @@ -155,6 +157,9 @@ function main() {} set dialogController(dialogController: ((CustomDialogController | null) | undefined)) get dialogController(): ((CustomDialogController | null) | undefined) + set __options_has_dialogController(__options_has_dialogController: (boolean | undefined)) + + get __options_has_dialogController(): (boolean | undefined) } `; diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/custom-dialog/declare-custom-dialog.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/custom-dialog/declare-custom-dialog.test.ts index bbbd0eb25dbfa475b8e28e00d12d14128013cf15..23f9b2574c4eb03f7d0b1013d85f8666af0bcbfa 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/custom-dialog/declare-custom-dialog.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/custom-dialog/declare-custom-dialog.test.ts @@ -137,15 +137,24 @@ function main() {} set aaController(aaController: ((CustomDialogController | undefined) | undefined)) get aaController(): ((CustomDialogController | undefined) | undefined) + set __options_has_aaController(__options_has_aaController: (boolean | undefined)) + + get __options_has_aaController(): (boolean | undefined) set text(text: (string | undefined)) get text(): (string | undefined) set __backing_text(__backing_text: (IStateDecoratedVariable | undefined)) get __backing_text(): (IStateDecoratedVariable | undefined) + set __options_has_text(__options_has_text: (boolean | undefined)) + + get __options_has_text(): (boolean | undefined) set hh(hh: (string | undefined)) get hh(): (string | undefined) + set __options_has_hh(__options_has_hh: (boolean | undefined)) + + get __options_has_hh(): (boolean | undefined) } @@ -153,6 +162,9 @@ function main() {} set dialogController(dialogController: ((CustomDialogController | null) | undefined)) get dialogController(): ((CustomDialogController | null) | undefined) + set __options_has_dialogController(__options_has_dialogController: (boolean | undefined)) + + get __options_has_dialogController(): (boolean | undefined) } @@ -160,6 +172,9 @@ function main() {} set dialogController(dialogController: ((CustomDialogController | null) | undefined)) get dialogController(): ((CustomDialogController | null) | undefined) + set __options_has_dialogController(__options_has_dialogController: (boolean | undefined)) + + get __options_has_dialogController(): (boolean | undefined) } `; diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/custom-dialog/extends-dialog-controller.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/custom-dialog/extends-dialog-controller.test.ts index f7ab1a6ec4d9a1dcc3edc47a6e03ad6d0a024f48..ca32aab2ac9cbd09e95bb7ec89251135414fef04 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/custom-dialog/extends-dialog-controller.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/custom-dialog/extends-dialog-controller.test.ts @@ -156,6 +156,9 @@ class DialogControllerV3 extends DialogControllerV2 { set aaController(aaController: ((CustomDialogController | undefined) | undefined)) get aaController(): ((CustomDialogController | undefined) | undefined) + set __options_has_aaController(__options_has_aaController: (boolean | undefined)) + + get __options_has_aaController(): (boolean | undefined) } @@ -163,6 +166,9 @@ class DialogControllerV3 extends DialogControllerV2 { set dialogController(dialogController: ((CustomDialogController | null) | undefined)) get dialogController(): ((CustomDialogController | null) | undefined) + set __options_has_dialogController(__options_has_dialogController: (boolean | undefined)) + + get __options_has_dialogController(): (boolean | undefined) } `; diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/decorator-no-type.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/decorator-no-type.test.ts index f726ecd68a44c8f99046d705f51033d4ed5ce62f..5d0255fc674b3e1ff68b8fdb1f97d59d9dc82cd2 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/decorator-no-type.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/decorator-no-type.test.ts @@ -52,7 +52,7 @@ import { memo as memo } from "arkui.stateManagement.runtime"; import { IProvideDecoratedVariable as IProvideDecoratedVariable } from "arkui.stateManagement.decorator"; -import { IPropDecoratedVariable as IPropDecoratedVariable } from "arkui.stateManagement.decorator"; +import { IPropRefDecoratedVariable as IPropRefDecoratedVariable } from "arkui.stateManagement.decorator"; import { IStateDecoratedVariable as IStateDecoratedVariable } from "arkui.stateManagement.decorator"; @@ -80,12 +80,13 @@ import { CustomComponent as CustomComponent } from "arkui.component.customCompon import { Component as Component, ComponentV2 as ComponentV2, CustomDialog as CustomDialog } from "@ohos.arkui.component"; -import { State as State, Prop as Prop, Provide as Provide, Event as Event, Local as Local, Param as Param } from "@ohos.arkui.stateManagement"; +import { State as State, PropRef as PropRef, Provide as Provide, Event as Event, Local as Local, Param as Param } from "@ohos.arkui.stateManagement"; import { Provider as Provider, Consumer as Consumer, Once as Once, Observed as Observed, ObservedV2 as ObservedV2, Trace as Trace, Track as Track } from "@ohos.arkui.stateManagement"; function main() {} + class Per { public num: number; @@ -257,7 +258,7 @@ final class StateType extends BaseEnum { public __initializeStruct(initializers: (__Options_Parent | undefined), @memo() content: ((()=> void) | undefined)): void { this.__backing_stateVar1 = STATE_MGMT_FACTORY.makeState(this, "stateVar1", (((({let gensym___213853607 = initializers; (((gensym___213853607) == (null)) ? undefined : gensym___213853607.stateVar1)})) ?? (new Per(6))) as Per)); - this.__backing_stateVar2 = STATE_MGMT_FACTORY.makeProp>(this, "stateVar2", (((({let gensym___113574154 = initializers; + this.__backing_stateVar2 = STATE_MGMT_FACTORY.makePropRef>(this, "stateVar2", (((({let gensym___113574154 = initializers; (((gensym___113574154) == (null)) ? undefined : gensym___113574154.stateVar2)})) ?? (new Array(3, 6, 8))) as Array)); this.__backing_stateVar3 = STATE_MGMT_FACTORY.makeProvide(this, "stateVar3", "stateVar3", (((({let gensym___120612294 = initializers; (((gensym___120612294) == (null)) ? undefined : gensym___120612294.stateVar3)})) ?? (StateType.TYPE3)) as StateType), false); @@ -274,8 +275,8 @@ final class StateType extends BaseEnum { } public __updateStruct(initializers: (__Options_Parent | undefined)): void { - if (((({let gensym___130780487 = initializers; - (((gensym___130780487) == (null)) ? undefined : gensym___130780487.stateVar2)})) !== (undefined))) { + if (({let gensym___103591793 = initializers; + (((gensym___103591793) == (null)) ? undefined : gensym___103591793.__options_has_stateVar2)})) { this.__backing_stateVar2!.update((initializers!.stateVar2 as Array)); } } @@ -290,7 +291,7 @@ final class StateType extends BaseEnum { this.__backing_stateVar1!.set(value); } - private __backing_stateVar2?: IPropDecoratedVariable>; + private __backing_stateVar2?: IPropRefDecoratedVariable>; public get stateVar2(): Array { return this.__backing_stateVar2!.get(); @@ -389,12 +390,12 @@ final class StateType extends BaseEnum { } public __updateStruct(initializers: (__Options_V2Parent | undefined)): void { - if (((({let gensym___68371156 = initializers; - (((gensym___68371156) == (null)) ? undefined : gensym___68371156.stateVar9)})) !== (undefined))) { + if (({let gensym___220782256 = initializers; + (((gensym___220782256) == (null)) ? undefined : gensym___220782256.__options_has_stateVar9)})) { this.__backing_stateVar9!.update((initializers!.stateVar9 as Date)); } - if (((({let gensym___20754573 = initializers; - (((gensym___20754573) == (null)) ? undefined : gensym___20754573.stateVar10)})) !== (undefined))) { + if (({let gensym___252301725 = initializers; + (((gensym___252301725) == (null)) ? undefined : gensym___252301725.__options_has_stateVar10)})) { this.__backing_stateVar10!.update((initializers!.stateVar10 as Map)); } } @@ -540,12 +541,12 @@ final class StateType extends BaseEnum { } public __updateStruct(initializers: (__Options_CC | undefined)): void { - if (((({let gensym___177096870 = initializers; - (((gensym___177096870) == (null)) ? undefined : gensym___177096870.stateVar9)})) !== (undefined))) { + if (({let gensym___245065060 = initializers; + (((gensym___245065060) == (null)) ? undefined : gensym___245065060.__options_has_stateVar9)})) { this.__backing_stateVar9!.update((initializers!.stateVar9 as Date)); } - if (((({let gensym___35982320 = initializers; - (((gensym___35982320) == (null)) ? undefined : gensym___35982320.stateVar10)})) !== (undefined))) { + if (({let gensym___158661357 = initializers; + (((gensym___158661357) == (null)) ? undefined : gensym___158661357.__options_has_stateVar10)})) { this.__backing_stateVar10!.update((initializers!.stateVar10 as Map)); } } @@ -675,42 +676,66 @@ final class StateType extends BaseEnum { set __backing_stateVar1(__backing_stateVar1: (IStateDecoratedVariable | undefined)) get __backing_stateVar1(): (IStateDecoratedVariable | undefined) + set __options_has_stateVar1(__options_has_stateVar1: (boolean | undefined)) + + get __options_has_stateVar1(): (boolean | undefined) set stateVar2(stateVar2: (Any | undefined)) get stateVar2(): (Any | undefined) - set __backing_stateVar2(__backing_stateVar2: (IPropDecoratedVariable | undefined)) + set __backing_stateVar2(__backing_stateVar2: (IPropRefDecoratedVariable | undefined)) + + get __backing_stateVar2(): (IPropRefDecoratedVariable | undefined) + set __options_has_stateVar2(__options_has_stateVar2: (boolean | undefined)) - get __backing_stateVar2(): (IPropDecoratedVariable | undefined) + get __options_has_stateVar2(): (boolean | undefined) set stateVar3(stateVar3: (Any | undefined)) get stateVar3(): (Any | undefined) set __backing_stateVar3(__backing_stateVar3: (IProvideDecoratedVariable | undefined)) get __backing_stateVar3(): (IProvideDecoratedVariable | undefined) + set __options_has_stateVar3(__options_has_stateVar3: (boolean | undefined)) + + get __options_has_stateVar3(): (boolean | undefined) set stateVar8(stateVar8: (Any | undefined)) get stateVar8(): (Any | undefined) + set __options_has_stateVar8(__options_has_stateVar8: (boolean | undefined)) + + get __options_has_stateVar8(): (boolean | undefined) set stateVar9(stateVar9: (Any | undefined)) get stateVar9(): (Any | undefined) + set __options_has_stateVar9(__options_has_stateVar9: (boolean | undefined)) + + get __options_has_stateVar9(): (boolean | undefined) set stateVar11113(stateVar11113: (Any | undefined)) get stateVar11113(): (Any | undefined) set __backing_stateVar11113(__backing_stateVar11113: (IProvideDecoratedVariable | undefined)) get __backing_stateVar11113(): (IProvideDecoratedVariable | undefined) + set __options_has_stateVar11113(__options_has_stateVar11113: (boolean | undefined)) + + get __options_has_stateVar11113(): (boolean | undefined) set stateVar11114(stateVar11114: (Any | undefined)) get stateVar11114(): (Any | undefined) set __backing_stateVar11114(__backing_stateVar11114: (IProvideDecoratedVariable | undefined)) get __backing_stateVar11114(): (IProvideDecoratedVariable | undefined) + set __options_has_stateVar11114(__options_has_stateVar11114: (boolean | undefined)) + + get __options_has_stateVar11114(): (boolean | undefined) set stateVar11115(stateVar11115: (Any | undefined)) get stateVar11115(): (Any | undefined) set __backing_stateVar11115(__backing_stateVar11115: (IStateDecoratedVariable | undefined)) get __backing_stateVar11115(): (IStateDecoratedVariable | undefined) + set __options_has_stateVar11115(__options_has_stateVar11115: (boolean | undefined)) + + get __options_has_stateVar11115(): (boolean | undefined) } @@ -721,66 +746,102 @@ final class StateType extends BaseEnum { @Param() set __backing_stateVar4(__backing_stateVar4: (IParamOnceDecoratedVariable | undefined)) @Param() get __backing_stateVar4(): (IParamOnceDecoratedVariable | undefined) + set __options_has_stateVar4(__options_has_stateVar4: (boolean | undefined)) + + get __options_has_stateVar4(): (boolean | undefined) set stateVar5(stateVar5: (Any | undefined)) get stateVar5(): (Any | undefined) set __backing_stateVar5(__backing_stateVar5: (ILocalDecoratedVariable | undefined)) get __backing_stateVar5(): (ILocalDecoratedVariable | undefined) + set __options_has_stateVar5(__options_has_stateVar5: (boolean | undefined)) + + get __options_has_stateVar5(): (boolean | undefined) set stateVar6(stateVar6: (Any | undefined)) get stateVar6(): (Any | undefined) set __backing_stateVar6(__backing_stateVar6: (ILocalDecoratedVariable | undefined)) get __backing_stateVar6(): (ILocalDecoratedVariable | undefined) + set __options_has_stateVar6(__options_has_stateVar6: (boolean | undefined)) + + get __options_has_stateVar6(): (boolean | undefined) set stateVar7(stateVar7: (Any | undefined)) get stateVar7(): (Any | undefined) + set __options_has_stateVar7(__options_has_stateVar7: (boolean | undefined)) + + get __options_has_stateVar7(): (boolean | undefined) set stateVar8(stateVar8: (Any | undefined)) get stateVar8(): (Any | undefined) + set __options_has_stateVar8(__options_has_stateVar8: (boolean | undefined)) + + get __options_has_stateVar8(): (boolean | undefined) set stateVar9(stateVar9: (Any | undefined)) get stateVar9(): (Any | undefined) set __backing_stateVar9(__backing_stateVar9: (IParamDecoratedVariable | undefined)) get __backing_stateVar9(): (IParamDecoratedVariable | undefined) + set __options_has_stateVar9(__options_has_stateVar9: (boolean | undefined)) + + get __options_has_stateVar9(): (boolean | undefined) set stateVar10(stateVar10: (Any | undefined)) get stateVar10(): (Any | undefined) set __backing_stateVar10(__backing_stateVar10: (IParamDecoratedVariable | undefined)) get __backing_stateVar10(): (IParamDecoratedVariable | undefined) + set __options_has_stateVar10(__options_has_stateVar10: (boolean | undefined)) + + get __options_has_stateVar10(): (boolean | undefined) set stateVar11(stateVar11: (Any | undefined)) get stateVar11(): (Any | undefined) @Param() set __backing_stateVar11(__backing_stateVar11: (IParamOnceDecoratedVariable | undefined)) @Param() get __backing_stateVar11(): (IParamOnceDecoratedVariable | undefined) + set __options_has_stateVar11(__options_has_stateVar11: (boolean | undefined)) + + get __options_has_stateVar11(): (boolean | undefined) set stateVar12(stateVar12: (Any | undefined)) get stateVar12(): (Any | undefined) set __backing_stateVar12(__backing_stateVar12: (IProviderDecoratedVariable | undefined)) get __backing_stateVar12(): (IProviderDecoratedVariable | undefined) + set __options_has_stateVar12(__options_has_stateVar12: (boolean | undefined)) + + get __options_has_stateVar12(): (boolean | undefined) set stateVar11111(stateVar11111: (Any | undefined)) get stateVar11111(): (Any | undefined) set __backing_stateVar11111(__backing_stateVar11111: (IConsumerDecoratedVariable | undefined)) get __backing_stateVar11111(): (IConsumerDecoratedVariable | undefined) + set __options_has_stateVar11111(__options_has_stateVar11111: (boolean | undefined)) + + get __options_has_stateVar11111(): (boolean | undefined) set stateVar11188(stateVar11188: (Any | undefined)) get stateVar11188(): (Any | undefined) set __backing_stateVar11188(__backing_stateVar11188: (IProviderDecoratedVariable | undefined)) get __backing_stateVar11188(): (IProviderDecoratedVariable | undefined) + set __options_has_stateVar11188(__options_has_stateVar11188: (boolean | undefined)) + + get __options_has_stateVar11188(): (boolean | undefined) set stateVar11112(stateVar11112: (Any | undefined)) get stateVar11112(): (Any | undefined) set __backing_stateVar11112(__backing_stateVar11112: (IConsumerDecoratedVariable | undefined)) get __backing_stateVar11112(): (IConsumerDecoratedVariable | undefined) + set __options_has_stateVar11112(__options_has_stateVar11112: (boolean | undefined)) + + get __options_has_stateVar11112(): (boolean | undefined) } @@ -791,69 +852,104 @@ final class StateType extends BaseEnum { @Param() set __backing_stateVar4(__backing_stateVar4: (IParamOnceDecoratedVariable | undefined)) @Param() get __backing_stateVar4(): (IParamOnceDecoratedVariable | undefined) + set __options_has_stateVar4(__options_has_stateVar4: (boolean | undefined)) + + get __options_has_stateVar4(): (boolean | undefined) set stateVar5(stateVar5: (Any | undefined)) get stateVar5(): (Any | undefined) set __backing_stateVar5(__backing_stateVar5: (ILocalDecoratedVariable | undefined)) get __backing_stateVar5(): (ILocalDecoratedVariable | undefined) + set __options_has_stateVar5(__options_has_stateVar5: (boolean | undefined)) + + get __options_has_stateVar5(): (boolean | undefined) set stateVar6(stateVar6: (Any | undefined)) get stateVar6(): (Any | undefined) set __backing_stateVar6(__backing_stateVar6: (ILocalDecoratedVariable | undefined)) get __backing_stateVar6(): (ILocalDecoratedVariable | undefined) + set __options_has_stateVar6(__options_has_stateVar6: (boolean | undefined)) + + get __options_has_stateVar6(): (boolean | undefined) set stateVar7(stateVar7: (Any | undefined)) get stateVar7(): (Any | undefined) + set __options_has_stateVar7(__options_has_stateVar7: (boolean | undefined)) + + get __options_has_stateVar7(): (boolean | undefined) set stateVar8(stateVar8: (Any | undefined)) get stateVar8(): (Any | undefined) + set __options_has_stateVar8(__options_has_stateVar8: (boolean | undefined)) + + get __options_has_stateVar8(): (boolean | undefined) set stateVar9(stateVar9: (Any | undefined)) get stateVar9(): (Any | undefined) set __backing_stateVar9(__backing_stateVar9: (IParamDecoratedVariable | undefined)) get __backing_stateVar9(): (IParamDecoratedVariable | undefined) + set __options_has_stateVar9(__options_has_stateVar9: (boolean | undefined)) + + get __options_has_stateVar9(): (boolean | undefined) set stateVar10(stateVar10: (Any | undefined)) get stateVar10(): (Any | undefined) set __backing_stateVar10(__backing_stateVar10: (IParamDecoratedVariable | undefined)) get __backing_stateVar10(): (IParamDecoratedVariable | undefined) + set __options_has_stateVar10(__options_has_stateVar10: (boolean | undefined)) + + get __options_has_stateVar10(): (boolean | undefined) set stateVar11(stateVar11: (Any | undefined)) get stateVar11(): (Any | undefined) @Param() set __backing_stateVar11(__backing_stateVar11: (IParamOnceDecoratedVariable | undefined)) @Param() get __backing_stateVar11(): (IParamOnceDecoratedVariable | undefined) + set __options_has_stateVar11(__options_has_stateVar11: (boolean | undefined)) + + get __options_has_stateVar11(): (boolean | undefined) set stateVar12(stateVar12: (Any | undefined)) get stateVar12(): (Any | undefined) set __backing_stateVar12(__backing_stateVar12: (IProviderDecoratedVariable | undefined)) get __backing_stateVar12(): (IProviderDecoratedVariable | undefined) + set __options_has_stateVar12(__options_has_stateVar12: (boolean | undefined)) + + get __options_has_stateVar12(): (boolean | undefined) set stateVar11111(stateVar11111: (Any | undefined)) get stateVar11111(): (Any | undefined) set __backing_stateVar11111(__backing_stateVar11111: (IConsumerDecoratedVariable | undefined)) get __backing_stateVar11111(): (IConsumerDecoratedVariable | undefined) + set __options_has_stateVar11111(__options_has_stateVar11111: (boolean | undefined)) + + get __options_has_stateVar11111(): (boolean | undefined) set stateVar11188(stateVar11188: (Any | undefined)) get stateVar11188(): (Any | undefined) set __backing_stateVar11188(__backing_stateVar11188: (IProviderDecoratedVariable | undefined)) get __backing_stateVar11188(): (IProviderDecoratedVariable | undefined) + set __options_has_stateVar11188(__options_has_stateVar11188: (boolean | undefined)) + + get __options_has_stateVar11188(): (boolean | undefined) set stateVar11112(stateVar11112: (Any | undefined)) get stateVar11112(): (Any | undefined) set __backing_stateVar11112(__backing_stateVar11112: (IConsumerDecoratedVariable | undefined)) get __backing_stateVar11112(): (IConsumerDecoratedVariable | undefined) + set __options_has_stateVar11112(__options_has_stateVar11112: (boolean | undefined)) + + get __options_has_stateVar11112(): (boolean | undefined) } - `; function testParsedAndCheckedTransformer(this: PluginTestContext): void { diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/event/event-initialize.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/event/event-initialize.test.ts index e5e8c36a3612696f90f207bc94d554a04ffbdf4b..79dc6cf375ededf33afe05f4cc4ace965c0dfd5e 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/event/event-initialize.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/event/event-initialize.test.ts @@ -90,15 +90,20 @@ import { Event as Event, Param as Param, Local as Local } from "@ohos.arkui.stat @ComponentV2() export interface __Options_Child { index?: number; @Param() __backing_index?: number; + __options_has_index?: boolean; changeIndex?: ((val: number)=> void); + __options_has_changeIndex?: boolean; testEvent?: ((val: number)=> number); + __options_has_testEvent?: boolean; testEvent2?: ((val: number)=> number); + __options_has_testEvent2?: boolean; } @ComponentV2() export interface __Options_Index { index?: number; @Local() __backing_index?: number; + __options_has_index?: boolean; } `; @@ -137,8 +142,8 @@ function main() {} } public __updateStruct(initializers: (__Options_Child | undefined)): void { - if (((({let gensym___91647805 = initializers; - (((gensym___91647805) == (null)) ? undefined : gensym___91647805.index)})) !== (undefined))) { + if (({let gensym___90897897 = initializers; + (((gensym___90897897) == (null)) ? undefined : gensym___90897897.__options_has_index)})) { this.__backing_index!.update((initializers!.index as number)); } } @@ -218,10 +223,12 @@ function main() {} return new Child(); }), { index: this.index, + __options_has_index: true, changeIndex: ((val: number) => { this.index = val; console.log(\`in changeIndex \${this.index}\`); }), + __options_has_changeIndex: true, }, undefined, undefined); })); } @@ -237,15 +244,27 @@ function main() {} set __backing_index(__backing_index: (IParamDecoratedVariable | undefined)) get __backing_index(): (IParamDecoratedVariable | undefined) + set __options_has_index(__options_has_index: (boolean | undefined)) + + get __options_has_index(): (boolean | undefined) set changeIndex(changeIndex: (((val: number)=> void) | undefined)) get changeIndex(): (((val: number)=> void) | undefined) + set __options_has_changeIndex(__options_has_changeIndex: (boolean | undefined)) + + get __options_has_changeIndex(): (boolean | undefined) set testEvent(testEvent: (((val: number)=> number) | undefined)) get testEvent(): (((val: number)=> number) | undefined) + set __options_has_testEvent(__options_has_testEvent: (boolean | undefined)) + + get __options_has_testEvent(): (boolean | undefined) set testEvent2(testEvent2: (((val: number)=> number) | undefined)) get testEvent2(): (((val: number)=> number) | undefined) + set __options_has_testEvent2(__options_has_testEvent2: (boolean | undefined)) + + get __options_has_testEvent2(): (boolean | undefined) } @@ -256,6 +275,9 @@ function main() {} set __backing_index(__backing_index: (ILocalDecoratedVariable | undefined)) get __backing_index(): (ILocalDecoratedVariable | undefined) + set __options_has_index(__options_has_index: (boolean | undefined)) + + get __options_has_index(): (boolean | undefined) } `; diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/link/link-basic-type.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/link/link-basic-type.test.ts index 2ce87652911deab846655a760e2f754395687344..28431a068d2ea024aff1d316d7b3c918865c952a 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/link/link-basic-type.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/link/link-basic-type.test.ts @@ -38,7 +38,6 @@ const parsedTransform: Plugins = { }; const expectedScript: string = ` - import { memo as memo } from "arkui.stateManagement.runtime"; import { STATE_MGMT_FACTORY as STATE_MGMT_FACTORY } from "arkui.stateManagement.decorator"; @@ -47,7 +46,6 @@ import { LinkSourceType as LinkSourceType } from "arkui.stateManagement.decorato import { ILinkDecoratedVariable as ILinkDecoratedVariable } from "arkui.stateManagement.decorator"; - import { CustomComponent as CustomComponent } from "arkui.component.customComponent"; import { Component as Component } from "@ohos.arkui.component"; @@ -56,28 +54,26 @@ import { Link as Link } from "@ohos.arkui.stateManagement"; function main() {} - - @Component() final struct LinkParent extends CustomComponent { public __initializeStruct(initializers: (__Options_LinkParent | undefined), @memo() content: ((()=> void) | undefined)): void { - if (({let gensym___11910109 = initializers; - (((gensym___11910109) == (null)) ? undefined : gensym___11910109.__backing_linkVar1)})) { + if (({let gensym___184416899 = initializers; + (((gensym___184416899) == (null)) ? undefined : gensym___184416899.__options_has_linkVar1)})) { this.__backing_linkVar1 = STATE_MGMT_FACTORY.makeLink(this, "linkVar1", initializers!.__backing_linkVar1!); }; - if (({let gensym___181684045 = initializers; - (((gensym___181684045) == (null)) ? undefined : gensym___181684045.__backing_linkVar2)})) { + if (({let gensym___82966591 = initializers; + (((gensym___82966591) == (null)) ? undefined : gensym___82966591.__options_has_linkVar2)})) { this.__backing_linkVar2 = STATE_MGMT_FACTORY.makeLink(this, "linkVar2", initializers!.__backing_linkVar2!); }; - if (({let gensym___24446313 = initializers; - (((gensym___24446313) == (null)) ? undefined : gensym___24446313.__backing_linkVar3)})) { + if (({let gensym___55498955 = initializers; + (((gensym___55498955) == (null)) ? undefined : gensym___55498955.__options_has_linkVar3)})) { this.__backing_linkVar3 = STATE_MGMT_FACTORY.makeLink(this, "linkVar3", initializers!.__backing_linkVar3!); }; - if (({let gensym___167989826 = initializers; - (((gensym___167989826) == (null)) ? undefined : gensym___167989826.__backing_linkVar4)})) { + if (({let gensym___231322030 = initializers; + (((gensym___231322030) == (null)) ? undefined : gensym___231322030.__options_has_linkVar4)})) { this.__backing_linkVar4 = STATE_MGMT_FACTORY.makeLink(this, "linkVar4", initializers!.__backing_linkVar4!); }; - if (({let gensym___157566097 = initializers; - (((gensym___157566097) == (null)) ? undefined : gensym___157566097.__backing_linkVar5)})) { + if (({let gensym___2576517 = initializers; + (((gensym___2576517) == (null)) ? undefined : gensym___2576517.__options_has_linkVar5)})) { this.__backing_linkVar5 = STATE_MGMT_FACTORY.makeLink(this, "linkVar5", initializers!.__backing_linkVar5!); }; } @@ -149,30 +145,45 @@ function main() {} set __backing_linkVar1(__backing_linkVar1: (LinkSourceType | undefined)) get __backing_linkVar1(): (LinkSourceType | undefined) + set __options_has_linkVar1(__options_has_linkVar1: (boolean | undefined)) + + get __options_has_linkVar1(): (boolean | undefined) @__Link_intrinsic() set linkVar2(linkVar2: (number | undefined)) @__Link_intrinsic() get linkVar2(): (number | undefined) set __backing_linkVar2(__backing_linkVar2: (LinkSourceType | undefined)) get __backing_linkVar2(): (LinkSourceType | undefined) + set __options_has_linkVar2(__options_has_linkVar2: (boolean | undefined)) + + get __options_has_linkVar2(): (boolean | undefined) @__Link_intrinsic() set linkVar3(linkVar3: (boolean | undefined)) @__Link_intrinsic() get linkVar3(): (boolean | undefined) set __backing_linkVar3(__backing_linkVar3: (LinkSourceType | undefined)) get __backing_linkVar3(): (LinkSourceType | undefined) + set __options_has_linkVar3(__options_has_linkVar3: (boolean | undefined)) + + get __options_has_linkVar3(): (boolean | undefined) @__Link_intrinsic() set linkVar4(linkVar4: (undefined | undefined)) @__Link_intrinsic() get linkVar4(): (undefined | undefined) set __backing_linkVar4(__backing_linkVar4: (LinkSourceType | undefined)) get __backing_linkVar4(): (LinkSourceType | undefined) + set __options_has_linkVar4(__options_has_linkVar4: (boolean | undefined)) + + get __options_has_linkVar4(): (boolean | undefined) @__Link_intrinsic() set linkVar5(linkVar5: (null | undefined)) @__Link_intrinsic() get linkVar5(): (null | undefined) set __backing_linkVar5(__backing_linkVar5: (LinkSourceType | undefined)) get __backing_linkVar5(): (LinkSourceType | undefined) + set __options_has_linkVar5(__options_has_linkVar5: (boolean | undefined)) + + get __options_has_linkVar5(): (boolean | undefined) } `; diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/link/link-complex-type.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/link/link-complex-type.test.ts index f174a08a5e213ea3cc0616f62777199123fbcfac..2f26f551d1a7a1dfc1d5a9de60da662ad88a66ef 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/link/link-complex-type.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/link/link-complex-type.test.ts @@ -46,7 +46,6 @@ import { LinkSourceType as LinkSourceType } from "arkui.stateManagement.decorato import { ILinkDecoratedVariable as ILinkDecoratedVariable } from "arkui.stateManagement.decorator"; - import { CustomComponent as CustomComponent } from "arkui.component.customComponent"; import { Component as Component } from "@ohos.arkui.component"; @@ -134,52 +133,52 @@ final class LinkType extends BaseEnum { @Component() final struct Parent extends CustomComponent { public __initializeStruct(initializers: (__Options_Parent | undefined), @memo() content: ((()=> void) | undefined)): void { - if (({let gensym___11910109 = initializers; - (((gensym___11910109) == (null)) ? undefined : gensym___11910109.__backing_linkVar1)})) { + if (({let gensym___184416899 = initializers; + (((gensym___184416899) == (null)) ? undefined : gensym___184416899.__options_has_linkVar1)})) { this.__backing_linkVar1 = STATE_MGMT_FACTORY.makeLink(this, "linkVar1", initializers!.__backing_linkVar1!); }; - if (({let gensym___181684045 = initializers; - (((gensym___181684045) == (null)) ? undefined : gensym___181684045.__backing_linkVar2)})) { + if (({let gensym___82966591 = initializers; + (((gensym___82966591) == (null)) ? undefined : gensym___82966591.__options_has_linkVar2)})) { this.__backing_linkVar2 = STATE_MGMT_FACTORY.makeLink>(this, "linkVar2", initializers!.__backing_linkVar2!); }; - if (({let gensym___24446313 = initializers; - (((gensym___24446313) == (null)) ? undefined : gensym___24446313.__backing_linkVar3)})) { + if (({let gensym___55498955 = initializers; + (((gensym___55498955) == (null)) ? undefined : gensym___55498955.__options_has_linkVar3)})) { this.__backing_linkVar3 = STATE_MGMT_FACTORY.makeLink(this, "linkVar3", initializers!.__backing_linkVar3!); }; - if (({let gensym___167989826 = initializers; - (((gensym___167989826) == (null)) ? undefined : gensym___167989826.__backing_linkVar4)})) { + if (({let gensym___231322030 = initializers; + (((gensym___231322030) == (null)) ? undefined : gensym___231322030.__options_has_linkVar4)})) { this.__backing_linkVar4 = STATE_MGMT_FACTORY.makeLink>(this, "linkVar4", initializers!.__backing_linkVar4!); }; - if (({let gensym___157566097 = initializers; - (((gensym___157566097) == (null)) ? undefined : gensym___157566097.__backing_linkVar5)})) { + if (({let gensym___2576517 = initializers; + (((gensym___2576517) == (null)) ? undefined : gensym___2576517.__options_has_linkVar5)})) { this.__backing_linkVar5 = STATE_MGMT_FACTORY.makeLink>(this, "linkVar5", initializers!.__backing_linkVar5!); }; - if (({let gensym___60105491 = initializers; - (((gensym___60105491) == (null)) ? undefined : gensym___60105491.__backing_linkVar6)})) { + if (({let gensym___11281112 = initializers; + (((gensym___11281112) == (null)) ? undefined : gensym___11281112.__options_has_linkVar6)})) { this.__backing_linkVar6 = STATE_MGMT_FACTORY.makeLink>(this, "linkVar6", initializers!.__backing_linkVar6!); }; - if (({let gensym___3429048 = initializers; - (((gensym___3429048) == (null)) ? undefined : gensym___3429048.__backing_linkVar7)})) { + if (({let gensym___228477447 = initializers; + (((gensym___228477447) == (null)) ? undefined : gensym___228477447.__options_has_linkVar7)})) { this.__backing_linkVar7 = STATE_MGMT_FACTORY.makeLink>(this, "linkVar7", initializers!.__backing_linkVar7!); }; - if (({let gensym___139916435 = initializers; - (((gensym___139916435) == (null)) ? undefined : gensym___139916435.__backing_linkVar8)})) { + if (({let gensym___82513833 = initializers; + (((gensym___82513833) == (null)) ? undefined : gensym___82513833.__options_has_linkVar8)})) { this.__backing_linkVar8 = STATE_MGMT_FACTORY.makeLink<((sr: string)=> void)>(this, "linkVar8", initializers!.__backing_linkVar8!); }; - if (({let gensym___145003260 = initializers; - (((gensym___145003260) == (null)) ? undefined : gensym___145003260.__backing_linkVar9)})) { + if (({let gensym___218466927 = initializers; + (((gensym___218466927) == (null)) ? undefined : gensym___218466927.__options_has_linkVar9)})) { this.__backing_linkVar9 = STATE_MGMT_FACTORY.makeLink(this, "linkVar9", initializers!.__backing_linkVar9!); }; - if (({let gensym___122643185 = initializers; - (((gensym___122643185) == (null)) ? undefined : gensym___122643185.__backing_linkVar10)})) { + if (({let gensym___190376050 = initializers; + (((gensym___190376050) == (null)) ? undefined : gensym___190376050.__options_has_linkVar10)})) { this.__backing_linkVar10 = STATE_MGMT_FACTORY.makeLink>(this, "linkVar10", initializers!.__backing_linkVar10!); }; - if (({let gensym___222468503 = initializers; - (((gensym___222468503) == (null)) ? undefined : gensym___222468503.__backing_linkVar11)})) { + if (({let gensym___64181673 = initializers; + (((gensym___64181673) == (null)) ? undefined : gensym___64181673.__options_has_linkVar11)})) { this.__backing_linkVar11 = STATE_MGMT_FACTORY.makeLink<(string | number)>(this, "linkVar11", initializers!.__backing_linkVar11!); }; - if (({let gensym___243301539 = initializers; - (((gensym___243301539) == (null)) ? undefined : gensym___243301539.__backing_linkVar12)})) { + if (({let gensym___134911804 = initializers; + (((gensym___134911804) == (null)) ? undefined : gensym___134911804.__options_has_linkVar12)})) { this.__backing_linkVar12 = STATE_MGMT_FACTORY.makeLink<(Set | Per)>(this, "linkVar12", initializers!.__backing_linkVar12!); }; } @@ -321,72 +320,108 @@ final class LinkType extends BaseEnum { set __backing_linkVar1(__backing_linkVar1: (LinkSourceType | undefined)) get __backing_linkVar1(): (LinkSourceType | undefined) + set __options_has_linkVar1(__options_has_linkVar1: (boolean | undefined)) + + get __options_has_linkVar1(): (boolean | undefined) @__Link_intrinsic() set linkVar2(linkVar2: (Array | undefined)) @__Link_intrinsic() get linkVar2(): (Array | undefined) set __backing_linkVar2(__backing_linkVar2: (LinkSourceType> | undefined)) get __backing_linkVar2(): (LinkSourceType> | undefined) + set __options_has_linkVar2(__options_has_linkVar2: (boolean | undefined)) + + get __options_has_linkVar2(): (boolean | undefined) @__Link_intrinsic() set linkVar3(linkVar3: (LinkType | undefined)) @__Link_intrinsic() get linkVar3(): (LinkType | undefined) set __backing_linkVar3(__backing_linkVar3: (LinkSourceType | undefined)) get __backing_linkVar3(): (LinkSourceType | undefined) + set __options_has_linkVar3(__options_has_linkVar3: (boolean | undefined)) + + get __options_has_linkVar3(): (boolean | undefined) @__Link_intrinsic() set linkVar4(linkVar4: (Set | undefined)) @__Link_intrinsic() get linkVar4(): (Set | undefined) set __backing_linkVar4(__backing_linkVar4: (LinkSourceType> | undefined)) get __backing_linkVar4(): (LinkSourceType> | undefined) + set __options_has_linkVar4(__options_has_linkVar4: (boolean | undefined)) + + get __options_has_linkVar4(): (boolean | undefined) @__Link_intrinsic() set linkVar5(linkVar5: (Array | undefined)) @__Link_intrinsic() get linkVar5(): (Array | undefined) set __backing_linkVar5(__backing_linkVar5: (LinkSourceType> | undefined)) get __backing_linkVar5(): (LinkSourceType> | undefined) + set __options_has_linkVar5(__options_has_linkVar5: (boolean | undefined)) + + get __options_has_linkVar5(): (boolean | undefined) @__Link_intrinsic() set linkVar6(linkVar6: (Array | undefined)) @__Link_intrinsic() get linkVar6(): (Array | undefined) set __backing_linkVar6(__backing_linkVar6: (LinkSourceType> | undefined)) get __backing_linkVar6(): (LinkSourceType> | undefined) + set __options_has_linkVar6(__options_has_linkVar6: (boolean | undefined)) + + get __options_has_linkVar6(): (boolean | undefined) @__Link_intrinsic() set linkVar7(linkVar7: (Array | undefined)) @__Link_intrinsic() get linkVar7(): (Array | undefined) set __backing_linkVar7(__backing_linkVar7: (LinkSourceType> | undefined)) get __backing_linkVar7(): (LinkSourceType> | undefined) + set __options_has_linkVar7(__options_has_linkVar7: (boolean | undefined)) + + get __options_has_linkVar7(): (boolean | undefined) @__Link_intrinsic() set linkVar8(linkVar8: (((sr: string)=> void) | undefined)) @__Link_intrinsic() get linkVar8(): (((sr: string)=> void) | undefined) set __backing_linkVar8(__backing_linkVar8: (LinkSourceType<((sr: string)=> void)> | undefined)) get __backing_linkVar8(): (LinkSourceType<((sr: string)=> void)> | undefined) + set __options_has_linkVar8(__options_has_linkVar8: (boolean | undefined)) + + get __options_has_linkVar8(): (boolean | undefined) @__Link_intrinsic() set linkVar9(linkVar9: (Date | undefined)) @__Link_intrinsic() get linkVar9(): (Date | undefined) set __backing_linkVar9(__backing_linkVar9: (LinkSourceType | undefined)) get __backing_linkVar9(): (LinkSourceType | undefined) + set __options_has_linkVar9(__options_has_linkVar9: (boolean | undefined)) + + get __options_has_linkVar9(): (boolean | undefined) @__Link_intrinsic() set linkVar10(linkVar10: (Map | undefined)) @__Link_intrinsic() get linkVar10(): (Map | undefined) set __backing_linkVar10(__backing_linkVar10: (LinkSourceType> | undefined)) get __backing_linkVar10(): (LinkSourceType> | undefined) + set __options_has_linkVar10(__options_has_linkVar10: (boolean | undefined)) + + get __options_has_linkVar10(): (boolean | undefined) @__Link_intrinsic() set linkVar11(linkVar11: ((string | number) | undefined)) @__Link_intrinsic() get linkVar11(): ((string | number) | undefined) set __backing_linkVar11(__backing_linkVar11: (LinkSourceType<(string | number)> | undefined)) get __backing_linkVar11(): (LinkSourceType<(string | number)> | undefined) + set __options_has_linkVar11(__options_has_linkVar11: (boolean | undefined)) + + get __options_has_linkVar11(): (boolean | undefined) @__Link_intrinsic() set linkVar12(linkVar12: ((Set | Per) | undefined)) @__Link_intrinsic() get linkVar12(): ((Set | Per) | undefined) set __backing_linkVar12(__backing_linkVar12: (LinkSourceType<(Set | Per)> | undefined)) get __backing_linkVar12(): (LinkSourceType<(Set | Per)> | undefined) + set __options_has_linkVar12(__options_has_linkVar12: (boolean | undefined)) + + get __options_has_linkVar12(): (boolean | undefined) } `; diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/link/link-to-link-prop-state.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/link/link-to-link-propref-state.test.ts similarity index 74% rename from arkui-plugins/test/ut/ui-plugins/decorators/link/link-to-link-prop-state.test.ts rename to arkui-plugins/test/ut/ui-plugins/decorators/link/link-to-link-propref-state.test.ts index 88ca21cd4824894ffa11c226ae8c46492649898c..91be1266d5355322fe89fae416b7afc6d30987ad 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/link/link-to-link-prop-state.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/link/link-to-link-propref-state.test.ts @@ -27,7 +27,7 @@ const BUILDER_LAMBDA_DIR_PATH: string = 'decorators/link'; const buildConfig: BuildConfig = mockBuildConfig(); buildConfig.compileFiles = [ - path.resolve(getRootPath(), MOCK_ENTRY_DIR_PATH, BUILDER_LAMBDA_DIR_PATH, 'link-to-link-prop-state.ets'), + path.resolve(getRootPath(), MOCK_ENTRY_DIR_PATH, BUILDER_LAMBDA_DIR_PATH, 'link-to-link-propref-state.ets'), ]; const pluginTester = new PluginTester('test @Link decorated variables passing to other variables', buildConfig); @@ -38,7 +38,7 @@ const parsedTransform: Plugins = { }; const expectedScript: string = ` -import { IPropDecoratedVariable as IPropDecoratedVariable } from "arkui.stateManagement.decorator"; +import { IPropRefDecoratedVariable as IPropRefDecoratedVariable } from "arkui.stateManagement.decorator"; import { IStateDecoratedVariable as IStateDecoratedVariable } from "arkui.stateManagement.decorator"; @@ -55,14 +55,15 @@ import { CustomComponent as CustomComponent } from "arkui.component.customCompon import { Component as Component, Column as Column, TextInput as TextInput } from "@ohos.arkui.component"; -import { Link as Link, State as State, Prop as Prop } from "@ohos.arkui.stateManagement"; +import { Link as Link, State as State, PropRef as PropRef } from "@ohos.arkui.stateManagement"; function main() {} + @Component() final struct Parant extends CustomComponent { public __initializeStruct(initializers: (__Options_Parant | undefined), @memo() content: ((()=> void) | undefined)): void { - if (({let gensym___10127521 = initializers; - (((gensym___10127521) == (null)) ? undefined : gensym___10127521.__backing_text1)})) { + if (({let gensym___194626867 = initializers; + (((gensym___194626867) == (null)) ? undefined : gensym___194626867.__options_has_text1)})) { this.__backing_text1 = STATE_MGMT_FACTORY.makeLink(this, "text1", initializers!.__backing_text1!); }; } @@ -88,9 +89,13 @@ function main() {} return new Child(); }), { __backing_childText: this.__backing_text1, + __options_has_childText: true, childText2: this.text1, + __options_has_childText2: true, childText3: this.text1, + __options_has_childText3: true, childText4: this.text1, + __options_has_childText4: true, }, undefined, undefined); })); } @@ -101,24 +106,24 @@ function main() {} @Component() final struct Child extends CustomComponent { public __initializeStruct(initializers: (__Options_Child | undefined), @memo() content: ((()=> void) | undefined)): void { - if (({let gensym___161337494 = initializers; - (((gensym___161337494) == (null)) ? undefined : gensym___161337494.__backing_childText)})) { + if (({let gensym___55490166 = initializers; + (((gensym___55490166) == (null)) ? undefined : gensym___55490166.__options_has_childText)})) { this.__backing_childText = STATE_MGMT_FACTORY.makeLink(this, "childText", initializers!.__backing_childText!); }; this.__backing_childText2 = STATE_MGMT_FACTORY.makeState(this, "childText2", ((({let gensym___95513066 = initializers; (((gensym___95513066) == (null)) ? undefined : gensym___95513066.childText2)})) ?? ("sss"))); - this.__backing_childText3 = STATE_MGMT_FACTORY.makeProp(this, "childText3", (initializers!.childText3 as string)); - this.__backing_childText4 = STATE_MGMT_FACTORY.makeProp(this, "childText4", ((({let gensym___162028107 = initializers; + this.__backing_childText3 = STATE_MGMT_FACTORY.makePropRef(this, "childText3", (initializers!.childText3 as string)); + this.__backing_childText4 = STATE_MGMT_FACTORY.makePropRef(this, "childText4", ((({let gensym___162028107 = initializers; (((gensym___162028107) == (null)) ? undefined : gensym___162028107.childText4)})) ?? ("cc"))); } public __updateStruct(initializers: (__Options_Child | undefined)): void { - if (((({let gensym___77632518 = initializers; - (((gensym___77632518) == (null)) ? undefined : gensym___77632518.childText3)})) !== (undefined))) { + if (({let gensym___240121011 = initializers; + (((gensym___240121011) == (null)) ? undefined : gensym___240121011.__options_has_childText3)})) { this.__backing_childText3!.update((initializers!.childText3 as string)); } - if (((({let gensym___250510741 = initializers; - (((gensym___250510741) == (null)) ? undefined : gensym___250510741.childText4)})) !== (undefined))) { + if (({let gensym___107610221 = initializers; + (((gensym___107610221) == (null)) ? undefined : gensym___107610221.__options_has_childText4)})) { this.__backing_childText4!.update((initializers!.childText4 as string)); } } @@ -143,7 +148,7 @@ function main() {} this.__backing_childText2!.set(value); } - private __backing_childText3?: IPropDecoratedVariable; + private __backing_childText3?: IPropRefDecoratedVariable; public get childText3(): string { return this.__backing_childText3!.get(); @@ -153,7 +158,7 @@ function main() {} this.__backing_childText3!.set(value); } - private __backing_childText4?: IPropDecoratedVariable; + private __backing_childText4?: IPropRefDecoratedVariable; public get childText4(): string { return this.__backing_childText4!.get(); @@ -182,6 +187,9 @@ function main() {} set __backing_text1(__backing_text1: (LinkSourceType | undefined)) get __backing_text1(): (LinkSourceType | undefined) + set __options_has_text1(__options_has_text1: (boolean | undefined)) + + get __options_has_text1(): (boolean | undefined) } @@ -192,24 +200,36 @@ function main() {} set __backing_childText(__backing_childText: (LinkSourceType | undefined)) get __backing_childText(): (LinkSourceType | undefined) + set __options_has_childText(__options_has_childText: (boolean | undefined)) + + get __options_has_childText(): (boolean | undefined) set childText2(childText2: (string | undefined)) get childText2(): (string | undefined) set __backing_childText2(__backing_childText2: (IStateDecoratedVariable | undefined)) get __backing_childText2(): (IStateDecoratedVariable | undefined) + set __options_has_childText2(__options_has_childText2: (boolean | undefined)) + + get __options_has_childText2(): (boolean | undefined) set childText3(childText3: (string | undefined)) get childText3(): (string | undefined) - set __backing_childText3(__backing_childText3: (IPropDecoratedVariable | undefined)) + set __backing_childText3(__backing_childText3: (IPropRefDecoratedVariable | undefined)) + + get __backing_childText3(): (IPropRefDecoratedVariable | undefined) + set __options_has_childText3(__options_has_childText3: (boolean | undefined)) - get __backing_childText3(): (IPropDecoratedVariable | undefined) + get __options_has_childText3(): (boolean | undefined) set childText4(childText4: (string | undefined)) get childText4(): (string | undefined) - set __backing_childText4(__backing_childText4: (IPropDecoratedVariable | undefined)) + set __backing_childText4(__backing_childText4: (IPropRefDecoratedVariable | undefined)) + + get __backing_childText4(): (IPropRefDecoratedVariable | undefined) + set __options_has_childText4(__options_has_childText4: (boolean | undefined)) - get __backing_childText4(): (IPropDecoratedVariable | undefined) + get __options_has_childText4(): (boolean | undefined) } `; diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/link/state-to-link.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/link/state-to-link.test.ts index c22a650babb3dbd6bdb5d6b62ebbd38b8d11432a..b2d0e95696d20d7a9e6f43f0284abdc8f41d50e9 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/link/state-to-link.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/link/state-to-link.test.ts @@ -56,7 +56,6 @@ import { PageLifeCycle as PageLifeCycle } from "arkui.component.customComponent" import { EntryPoint as EntryPoint } from "arkui.UserView"; - import { CustomComponent as CustomComponent } from "arkui.component.customComponent"; import { Component as Component, Entry as Entry, Column as Column, Button as Button, DatePicker as DatePicker, ClickEvent as ClickEvent } from "@ohos.arkui.component"; @@ -75,8 +74,8 @@ __EntryWrapper.RegisterNamedRouter("", new __EntryWrapper(), ({ @Component() final struct DateComponent extends CustomComponent { public __initializeStruct(initializers: (__Options_DateComponent | undefined), @memo() content: ((()=> void) | undefined)): void { - if (({let gensym___164314175 = initializers; - (((gensym___164314175) == (null)) ? undefined : gensym___164314175.__backing_selectedDate)})) { + if (({let gensym___27735436 = initializers; + (((gensym___27735436) == (null)) ? undefined : gensym___27735436.__options_has_selectedDate)})) { this.__backing_selectedDate = STATE_MGMT_FACTORY.makeLink(this, "selectedDate", initializers!.__backing_selectedDate!); }; } @@ -160,6 +159,7 @@ __EntryWrapper.RegisterNamedRouter("", new __EntryWrapper(), ({ return new DateComponent(); }), { __backing_selectedDate: this.__backing_parentSelectedDate, + __options_has_selectedDate: true, }, undefined, undefined); })); } @@ -177,6 +177,9 @@ __EntryWrapper.RegisterNamedRouter("", new __EntryWrapper(), ({ set __backing_selectedDate(__backing_selectedDate: (LinkSourceType | undefined)) get __backing_selectedDate(): (LinkSourceType | undefined) + set __options_has_selectedDate(__options_has_selectedDate: (boolean | undefined)) + + get __options_has_selectedDate(): (boolean | undefined) } @@ -187,6 +190,9 @@ __EntryWrapper.RegisterNamedRouter("", new __EntryWrapper(), ({ set __backing_parentSelectedDate(__backing_parentSelectedDate: (IStateDecoratedVariable | undefined)) get __backing_parentSelectedDate(): (IStateDecoratedVariable | undefined) + set __options_has_parentSelectedDate(__options_has_parentSelectedDate: (boolean | undefined)) + + get __options_has_parentSelectedDate(): (boolean | undefined) } diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/local/local-basic-type.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/local/local-basic-type.test.ts index fcfd6824a7a9f31fc325dc5cef14d5ac28dc85a8..4f48fb98fab0bf473265e6e18e3ab2549b8950fc 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/local/local-basic-type.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/local/local-basic-type.test.ts @@ -126,30 +126,45 @@ function main() {} set __backing_localVar1(__backing_localVar1: (ILocalDecoratedVariable | undefined)) get __backing_localVar1(): (ILocalDecoratedVariable | undefined) + set __options_has_localVar1(__options_has_localVar1: (boolean | undefined)) + + get __options_has_localVar1(): (boolean | undefined) set localVar2(localVar2: (number | undefined)) get localVar2(): (number | undefined) set __backing_localVar2(__backing_localVar2: (ILocalDecoratedVariable | undefined)) get __backing_localVar2(): (ILocalDecoratedVariable | undefined) + set __options_has_localVar2(__options_has_localVar2: (boolean | undefined)) + + get __options_has_localVar2(): (boolean | undefined) set localVar3(localVar3: (boolean | undefined)) get localVar3(): (boolean | undefined) set __backing_localVar3(__backing_localVar3: (ILocalDecoratedVariable | undefined)) get __backing_localVar3(): (ILocalDecoratedVariable | undefined) + set __options_has_localVar3(__options_has_localVar3: (boolean | undefined)) + + get __options_has_localVar3(): (boolean | undefined) set localVar4(localVar4: (undefined | undefined)) get localVar4(): (undefined | undefined) set __backing_localVar4(__backing_localVar4: (ILocalDecoratedVariable | undefined)) get __backing_localVar4(): (ILocalDecoratedVariable | undefined) + set __options_has_localVar4(__options_has_localVar4: (boolean | undefined)) + + get __options_has_localVar4(): (boolean | undefined) set localVar5(localVar5: (null | undefined)) get localVar5(): (null | undefined) set __backing_localVar5(__backing_localVar5: (ILocalDecoratedVariable | undefined)) get __backing_localVar5(): (ILocalDecoratedVariable | undefined) + set __options_has_localVar5(__options_has_localVar5: (boolean | undefined)) + + get __options_has_localVar5(): (boolean | undefined) } `; diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/local/local-complex-type.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/local/local-complex-type.test.ts index ad39578d1170981602e56865f07133133151628e..949fed1621a58aa02308db5a57252c36902d1e96 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/local/local-complex-type.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/local/local-complex-type.test.ts @@ -269,66 +269,99 @@ final class StateType extends BaseEnum { set __backing_localVar1(__backing_localVar1: (ILocalDecoratedVariable | undefined)) get __backing_localVar1(): (ILocalDecoratedVariable | undefined) + set __options_has_localVar1(__options_has_localVar1: (boolean | undefined)) + + get __options_has_localVar1(): (boolean | undefined) set localVar2(localVar2: (Array | undefined)) get localVar2(): (Array | undefined) set __backing_localVar2(__backing_localVar2: (ILocalDecoratedVariable> | undefined)) get __backing_localVar2(): (ILocalDecoratedVariable> | undefined) + set __options_has_localVar2(__options_has_localVar2: (boolean | undefined)) + + get __options_has_localVar2(): (boolean | undefined) set localVar3(localVar3: (StateType | undefined)) get localVar3(): (StateType | undefined) set __backing_localVar3(__backing_localVar3: (ILocalDecoratedVariable | undefined)) get __backing_localVar3(): (ILocalDecoratedVariable | undefined) + set __options_has_localVar3(__options_has_localVar3: (boolean | undefined)) + + get __options_has_localVar3(): (boolean | undefined) set localVar4(localVar4: (Set | undefined)) get localVar4(): (Set | undefined) set __backing_localVar4(__backing_localVar4: (ILocalDecoratedVariable> | undefined)) get __backing_localVar4(): (ILocalDecoratedVariable> | undefined) + set __options_has_localVar4(__options_has_localVar4: (boolean | undefined)) + + get __options_has_localVar4(): (boolean | undefined) set localVar5(localVar5: (Array | undefined)) get localVar5(): (Array | undefined) set __backing_localVar5(__backing_localVar5: (ILocalDecoratedVariable> | undefined)) get __backing_localVar5(): (ILocalDecoratedVariable> | undefined) + set __options_has_localVar5(__options_has_localVar5: (boolean | undefined)) + + get __options_has_localVar5(): (boolean | undefined) set localVar6(localVar6: (Array | undefined)) get localVar6(): (Array | undefined) set __backing_localVar6(__backing_localVar6: (ILocalDecoratedVariable> | undefined)) get __backing_localVar6(): (ILocalDecoratedVariable> | undefined) + set __options_has_localVar6(__options_has_localVar6: (boolean | undefined)) + + get __options_has_localVar6(): (boolean | undefined) set localVar7(localVar7: (Array | undefined)) get localVar7(): (Array | undefined) set __backing_localVar7(__backing_localVar7: (ILocalDecoratedVariable> | undefined)) get __backing_localVar7(): (ILocalDecoratedVariable> | undefined) + set __options_has_localVar7(__options_has_localVar7: (boolean | undefined)) + + get __options_has_localVar7(): (boolean | undefined) set localVar9(localVar9: (Date | undefined)) get localVar9(): (Date | undefined) set __backing_localVar9(__backing_localVar9: (ILocalDecoratedVariable | undefined)) get __backing_localVar9(): (ILocalDecoratedVariable | undefined) + set __options_has_localVar9(__options_has_localVar9: (boolean | undefined)) + + get __options_has_localVar9(): (boolean | undefined) set localVar10(localVar10: (Map | undefined)) get localVar10(): (Map | undefined) set __backing_localVar10(__backing_localVar10: (ILocalDecoratedVariable> | undefined)) get __backing_localVar10(): (ILocalDecoratedVariable> | undefined) + set __options_has_localVar10(__options_has_localVar10: (boolean | undefined)) + + get __options_has_localVar10(): (boolean | undefined) set localVar11(localVar11: ((string | number) | undefined)) get localVar11(): ((string | number) | undefined) set __backing_localVar11(__backing_localVar11: (ILocalDecoratedVariable<(string | number)> | undefined)) get __backing_localVar11(): (ILocalDecoratedVariable<(string | number)> | undefined) + set __options_has_localVar11(__options_has_localVar11: (boolean | undefined)) + + get __options_has_localVar11(): (boolean | undefined) set localVar12(localVar12: ((Set | Per) | undefined)) get localVar12(): ((Set | Per) | undefined) set __backing_localVar12(__backing_localVar12: (ILocalDecoratedVariable<(Set | Per)> | undefined)) get __backing_localVar12(): (ILocalDecoratedVariable<(Set | Per)> | undefined) + set __options_has_localVar12(__options_has_localVar12: (boolean | undefined)) + + get __options_has_localVar12(): (boolean | undefined) } `; diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/local/static-local.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/local/static-local.test.ts index b85513d93e3025ae35a0aea25a08269683a755d2..3676ad7b4ad562c1967a931bf8101d8f60ebc17b 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/local/static-local.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/local/static-local.test.ts @@ -108,18 +108,27 @@ class ABB { set __backing_localVar1(__backing_localVar1: (ILocalDecoratedVariable | undefined)) get __backing_localVar1(): (ILocalDecoratedVariable | undefined) + set __options_has_localVar1(__options_has_localVar1: (boolean | undefined)) + + get __options_has_localVar1(): (boolean | undefined) set localVar2(localVar2: (number | undefined)) get localVar2(): (number | undefined) set __backing_localVar2(__backing_localVar2: (ILocalDecoratedVariable | undefined)) get __backing_localVar2(): (ILocalDecoratedVariable | undefined) + set __options_has_localVar2(__options_has_localVar2: (boolean | undefined)) + + get __options_has_localVar2(): (boolean | undefined) set localVar3(localVar3: (ABB | undefined)) get localVar3(): (ABB | undefined) set __backing_localVar3(__backing_localVar3: (ILocalDecoratedVariable | undefined)) get __backing_localVar3(): (ILocalDecoratedVariable | undefined) + set __options_has_localVar3(__options_has_localVar3: (boolean | undefined)) + + get __options_has_localVar3(): (boolean | undefined) } `; diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/localstoragelink/localstoragelink-complex-type.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/localstoragelink/localstoragelink-complex-type.test.ts index d5e77e56caef6e0db9af39ba7c7f46bf3f65e6ac..ea1278cd2e8840573fd6689ea0cdb1ebb45661cd 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/localstoragelink/localstoragelink-complex-type.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/localstoragelink/localstoragelink-complex-type.test.ts @@ -150,6 +150,7 @@ final class Status extends BaseEnum { this.__backing_dateA = STATE_MGMT_FACTORY.makeLocalStorageLink(this, "Prop3", "dateA", new Date("2021-08-08")) this.__backing_setA = STATE_MGMT_FACTORY.makeLocalStorageLink>(this, "Prop4", "setA", new Set()) this.__backing_mapA = STATE_MGMT_FACTORY.makeLocalStorageLink>(this, "Prop5", "mapA", new Map()) + this.__backing_unionA = STATE_MGMT_FACTORY.makeLocalStorageLink<(string | undefined)>(this, "Prop6", "unionA", "") this.__backing_classA = STATE_MGMT_FACTORY.makeLocalStorageLink(this, "Prop7", "classA", new Person("John")) this.__backing_enumA = STATE_MGMT_FACTORY.makeLocalStorageLink(this, "Prop8", "enumA", Status.NotFound) } @@ -206,6 +207,16 @@ final class Status extends BaseEnum { this.__backing_mapA!.set(value); } + private __backing_unionA?: ILocalStorageLinkDecoratedVariable<(string | undefined)>; + + public get unionA(): (string | undefined) { + return this.__backing_unionA!.get(); + } + + public set unionA(value: (string | undefined)) { + this.__backing_unionA!.set(value); + } + private __backing_classA?: ILocalStorageLinkDecoratedVariable; public get classA(): Person { @@ -239,42 +250,72 @@ final class Status extends BaseEnum { set __backing_arrayA(__backing_arrayA: (ILocalStorageLinkDecoratedVariable> | undefined)) get __backing_arrayA(): (ILocalStorageLinkDecoratedVariable> | undefined) + set __options_has_arrayA(__options_has_arrayA: (boolean | undefined)) + + get __options_has_arrayA(): (boolean | undefined) set objectA(objectA: (Object | undefined)) get objectA(): (Object | undefined) set __backing_objectA(__backing_objectA: (ILocalStorageLinkDecoratedVariable | undefined)) get __backing_objectA(): (ILocalStorageLinkDecoratedVariable | undefined) + set __options_has_objectA(__options_has_objectA: (boolean | undefined)) + + get __options_has_objectA(): (boolean | undefined) set dateA(dateA: (Date | undefined)) get dateA(): (Date | undefined) set __backing_dateA(__backing_dateA: (ILocalStorageLinkDecoratedVariable | undefined)) get __backing_dateA(): (ILocalStorageLinkDecoratedVariable | undefined) + set __options_has_dateA(__options_has_dateA: (boolean | undefined)) + + get __options_has_dateA(): (boolean | undefined) set setA(setA: (Set | undefined)) get setA(): (Set | undefined) set __backing_setA(__backing_setA: (ILocalStorageLinkDecoratedVariable> | undefined)) get __backing_setA(): (ILocalStorageLinkDecoratedVariable> | undefined) + set __options_has_setA(__options_has_setA: (boolean | undefined)) + + get __options_has_setA(): (boolean | undefined) set mapA(mapA: (Map | undefined)) get mapA(): (Map | undefined) set __backing_mapA(__backing_mapA: (ILocalStorageLinkDecoratedVariable> | undefined)) get __backing_mapA(): (ILocalStorageLinkDecoratedVariable> | undefined) + set __options_has_mapA(__options_has_mapA: (boolean | undefined)) + + get __options_has_mapA(): (boolean | undefined) + set unionA(unionA: ((string | undefined) | undefined)) + + get unionA(): ((string | undefined) | undefined) + set __backing_unionA(__backing_unionA: (ILocalStorageLinkDecoratedVariable<(string | undefined)> | undefined)) + + get __backing_unionA(): (ILocalStorageLinkDecoratedVariable<(string | undefined)> | undefined) + set __options_has_unionA(__options_has_unionA: (boolean | undefined)) + + get __options_has_unionA(): (boolean | undefined) set classA(classA: (Person | undefined)) get classA(): (Person | undefined) set __backing_classA(__backing_classA: (ILocalStorageLinkDecoratedVariable | undefined)) get __backing_classA(): (ILocalStorageLinkDecoratedVariable | undefined) + set __options_has_classA(__options_has_classA: (boolean | undefined)) + + get __options_has_classA(): (boolean | undefined) set enumA(enumA: (Status | undefined)) get enumA(): (Status | undefined) set __backing_enumA(__backing_enumA: (ILocalStorageLinkDecoratedVariable | undefined)) get __backing_enumA(): (ILocalStorageLinkDecoratedVariable | undefined) + set __options_has_enumA(__options_has_enumA: (boolean | undefined)) + + get __options_has_enumA(): (boolean | undefined) } diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/localstoragelink/localstoragelink-primitive-type.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/localstoragelink/localstoragelink-primitive-type.test.ts index fea624d8dfba82ca82a499660ec0d7b428c21245..581f7c8e6887254df70ad24e4964c4af7d99e90e 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/localstoragelink/localstoragelink-primitive-type.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/localstoragelink/localstoragelink-primitive-type.test.ts @@ -119,18 +119,27 @@ __EntryWrapper.RegisterNamedRouter("", new __EntryWrapper(), ({ set __backing_numA(__backing_numA: (ILocalStorageLinkDecoratedVariable | undefined)) get __backing_numA(): (ILocalStorageLinkDecoratedVariable | undefined) + set __options_has_numA(__options_has_numA: (boolean | undefined)) + + get __options_has_numA(): (boolean | undefined) set stringA(stringA: (string | undefined)) get stringA(): (string | undefined) set __backing_stringA(__backing_stringA: (ILocalStorageLinkDecoratedVariable | undefined)) get __backing_stringA(): (ILocalStorageLinkDecoratedVariable | undefined) + set __options_has_stringA(__options_has_stringA: (boolean | undefined)) + + get __options_has_stringA(): (boolean | undefined) set booleanA(booleanA: (boolean | undefined)) get booleanA(): (boolean | undefined) set __backing_booleanA(__backing_booleanA: (ILocalStorageLinkDecoratedVariable | undefined)) get __backing_booleanA(): (ILocalStorageLinkDecoratedVariable | undefined) + set __options_has_booleanA(__options_has_booleanA: (boolean | undefined)) + + get __options_has_booleanA(): (boolean | undefined) } diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/localstorageprop-ref/localstorageprop-ref-complex-type.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/localstorageprop-ref/localstorageprop-ref-complex-type.test.ts index 8d6f9b383dd0a23eaf71b0361b1571be25b9218e..a1d42700d97526c57dd33d5912720953e8ddc00f 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/localstorageprop-ref/localstorageprop-ref-complex-type.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/localstorageprop-ref/localstorageprop-ref-complex-type.test.ts @@ -223,42 +223,63 @@ final class Status extends BaseEnum { set __backing_arrayB(__backing_arrayB: (ILocalStoragePropRefDecoratedVariable> | undefined)) get __backing_arrayB(): (ILocalStoragePropRefDecoratedVariable> | undefined) + set __options_has_arrayB(__options_has_arrayB: (boolean | undefined)) + + get __options_has_arrayB(): (boolean | undefined) set objectB(objectB: (Object | undefined)) get objectB(): (Object | undefined) set __backing_objectB(__backing_objectB: (ILocalStoragePropRefDecoratedVariable | undefined)) get __backing_objectB(): (ILocalStoragePropRefDecoratedVariable | undefined) + set __options_has_objectB(__options_has_objectB: (boolean | undefined)) + + get __options_has_objectB(): (boolean | undefined) set dateB(dateB: (Date | undefined)) get dateB(): (Date | undefined) set __backing_dateB(__backing_dateB: (ILocalStoragePropRefDecoratedVariable | undefined)) get __backing_dateB(): (ILocalStoragePropRefDecoratedVariable | undefined) + set __options_has_dateB(__options_has_dateB: (boolean | undefined)) + + get __options_has_dateB(): (boolean | undefined) set setB(setB: (Set | undefined)) get setB(): (Set | undefined) set __backing_setB(__backing_setB: (ILocalStoragePropRefDecoratedVariable> | undefined)) get __backing_setB(): (ILocalStoragePropRefDecoratedVariable> | undefined) + set __options_has_setB(__options_has_setB: (boolean | undefined)) + + get __options_has_setB(): (boolean | undefined) set mapB(mapB: (Map | undefined)) get mapB(): (Map | undefined) set __backing_mapB(__backing_mapB: (ILocalStoragePropRefDecoratedVariable> | undefined)) get __backing_mapB(): (ILocalStoragePropRefDecoratedVariable> | undefined) + set __options_has_mapB(__options_has_mapB: (boolean | undefined)) + + get __options_has_mapB(): (boolean | undefined) set classB(classB: (Person | undefined)) get classB(): (Person | undefined) set __backing_classB(__backing_classB: (ILocalStoragePropRefDecoratedVariable | undefined)) get __backing_classB(): (ILocalStoragePropRefDecoratedVariable | undefined) + set __options_has_classB(__options_has_classB: (boolean | undefined)) + + get __options_has_classB(): (boolean | undefined) set enumB(enumB: (Status | undefined)) get enumB(): (Status | undefined) set __backing_enumB(__backing_enumB: (ILocalStoragePropRefDecoratedVariable | undefined)) get __backing_enumB(): (ILocalStoragePropRefDecoratedVariable | undefined) + set __options_has_enumB(__options_has_enumB: (boolean | undefined)) + + get __options_has_enumB(): (boolean | undefined) } `; diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/localstorageprop-ref/localstorageprop-ref-primitive-type.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/localstorageprop-ref/localstorageprop-ref-primitive-type.test.ts index 407d8ea1233ee13d9dba68a8260940ac4c80a167..d73ad8837ac32846668df8c82ba88b5081029af7 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/localstorageprop-ref/localstorageprop-ref-primitive-type.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/localstorageprop-ref/localstorageprop-ref-primitive-type.test.ts @@ -126,30 +126,45 @@ function main() {} set __backing_numB(__backing_numB: (ILocalStoragePropRefDecoratedVariable | undefined)) get __backing_numB(): (ILocalStoragePropRefDecoratedVariable | undefined) + set __options_has_numB(__options_has_numB: (boolean | undefined)) + + get __options_has_numB(): (boolean | undefined) set stringB(stringB: (string | undefined)) get stringB(): (string | undefined) set __backing_stringB(__backing_stringB: (ILocalStoragePropRefDecoratedVariable | undefined)) get __backing_stringB(): (ILocalStoragePropRefDecoratedVariable | undefined) + set __options_has_stringB(__options_has_stringB: (boolean | undefined)) + + get __options_has_stringB(): (boolean | undefined) set booleanB(booleanB: (boolean | undefined)) get booleanB(): (boolean | undefined) set __backing_booleanB(__backing_booleanB: (ILocalStoragePropRefDecoratedVariable | undefined)) get __backing_booleanB(): (ILocalStoragePropRefDecoratedVariable | undefined) + set __options_has_booleanB(__options_has_booleanB: (boolean | undefined)) + + get __options_has_booleanB(): (boolean | undefined) set undefinedB(undefinedB: (undefined | undefined)) get undefinedB(): (undefined | undefined) set __backing_undefinedB(__backing_undefinedB: (ILocalStoragePropRefDecoratedVariable | undefined)) get __backing_undefinedB(): (ILocalStoragePropRefDecoratedVariable | undefined) + set __options_has_undefinedB(__options_has_undefinedB: (boolean | undefined)) + + get __options_has_undefinedB(): (boolean | undefined) set nullB(nullB: (null | undefined)) get nullB(): (null | undefined) set __backing_nullB(__backing_nullB: (ILocalStoragePropRefDecoratedVariable | undefined)) get __backing_nullB(): (ILocalStoragePropRefDecoratedVariable | undefined) + set __options_has_nullB(__options_has_nullB: (boolean | undefined)) + + get __options_has_nullB(): (boolean | undefined) } `; diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/monitor/enum-monitor-params.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/monitor/enum-monitor-params.test.ts index d7289b2b4b52a0c6fcb2c6eeb23234c5d519d91f..ed04cda5d5cc279e3d6d351a6da9db2e1b32ee71 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/monitor/enum-monitor-params.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/monitor/enum-monitor-params.test.ts @@ -274,6 +274,9 @@ final class MonitorNames extends BaseEnum { set __backing_varF(__backing_varF: (ILocalDecoratedVariable | undefined)) get __backing_varF(): (ILocalDecoratedVariable | undefined) + set __options_has_varF(__options_has_varF: (boolean | undefined)) + + get __options_has_varF(): (boolean | undefined) } `; diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/monitor/monitor-before-state-variable.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/monitor/monitor-before-state-variable.test.ts index 30dcef186ca41f79f038eb06cceba3a2436e1021..27ec76c7d2fd8409cd00b70afc1fa67f99e8f632 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/monitor/monitor-before-state-variable.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/monitor/monitor-before-state-variable.test.ts @@ -157,18 +157,27 @@ function main() {} set __backing_message(__backing_message: (ILocalDecoratedVariable | undefined)) get __backing_message(): (ILocalDecoratedVariable | undefined) + set __options_has_message(__options_has_message: (boolean | undefined)) + + get __options_has_message(): (boolean | undefined) set name(name: (string | undefined)) get name(): (string | undefined) set __backing_name(__backing_name: (ILocalDecoratedVariable | undefined)) get __backing_name(): (ILocalDecoratedVariable | undefined) + set __options_has_name(__options_has_name: (boolean | undefined)) + + get __options_has_name(): (boolean | undefined) set age(age: (number | undefined)) get age(): (number | undefined) set __backing_age(__backing_age: (ILocalDecoratedVariable | undefined)) get __backing_age(): (ILocalDecoratedVariable | undefined) + set __options_has_age(__options_has_age: (boolean | undefined)) + + get __options_has_age(): (boolean | undefined) } `; diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/monitor/monitor-in-observedv2-class.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/monitor/monitor-in-observedv2-class.test.ts index b98dbc0ab3c4c505e233803b185a77bf9061f837..24315e318456817d67837b81c02f9317386cd215 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/monitor/monitor-in-observedv2-class.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/monitor/monitor-in-observedv2-class.test.ts @@ -257,6 +257,9 @@ function main() {} set info(info: (Info | undefined)) get info(): (Info | undefined) + set __options_has_info(__options_has_info: (boolean | undefined)) + + get __options_has_info(): (boolean | undefined) } `; diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/monitor/monitor-in-struct.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/monitor/monitor-in-struct.test.ts index ecc359ecf977c6dca6e41c0d89d9315b6108d838..d29735f1f73ec4c180c23022dd7f591e8cf944d0 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/monitor/monitor-in-struct.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/monitor/monitor-in-struct.test.ts @@ -143,21 +143,29 @@ function main() {} set __backing_message(__backing_message: (ILocalDecoratedVariable | undefined)) get __backing_message(): (ILocalDecoratedVariable | undefined) + set __options_has_message(__options_has_message: (boolean | undefined)) + + get __options_has_message(): (boolean | undefined) set name(name: (string | undefined)) get name(): (string | undefined) set __backing_name(__backing_name: (ILocalDecoratedVariable | undefined)) get __backing_name(): (ILocalDecoratedVariable | undefined) + set __options_has_name(__options_has_name: (boolean | undefined)) + + get __options_has_name(): (boolean | undefined) set age(age: (number | undefined)) get age(): (number | undefined) set __backing_age(__backing_age: (ILocalDecoratedVariable | undefined)) get __backing_age(): (ILocalDecoratedVariable | undefined) + set __options_has_age(__options_has_age: (boolean | undefined)) + + get __options_has_age(): (boolean | undefined) } - `; function testParsedAndCheckedTransformer(this: PluginTestContext): void { diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/monitor/monitor-params.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/monitor/monitor-params.test.ts index 5479104e5cff28e1eef7d1057279cdefa7d8e63d..63ad17e81675eb352aa17a3a78b6f81f2bb889a8 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/monitor/monitor-params.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/monitor/monitor-params.test.ts @@ -324,21 +324,29 @@ class GGG { set __backing_per(__backing_per: (ILocalDecoratedVariable | undefined)) get __backing_per(): (ILocalDecoratedVariable | undefined) + set __options_has_per(__options_has_per: (boolean | undefined)) + + get __options_has_per(): (boolean | undefined) set v1(v1: (boolean | undefined)) get v1(): (boolean | undefined) set __backing_v1(__backing_v1: (ILocalDecoratedVariable | undefined)) get __backing_v1(): (ILocalDecoratedVariable | undefined) + set __options_has_v1(__options_has_v1: (boolean | undefined)) + + get __options_has_v1(): (boolean | undefined) set numArr(numArr: (Array | undefined)) get numArr(): (Array | undefined) set __backing_numArr(__backing_numArr: (ILocalDecoratedVariable> | undefined)) get __backing_numArr(): (ILocalDecoratedVariable> | undefined) + set __options_has_numArr(__options_has_numArr: (boolean | undefined)) + + get __options_has_numArr(): (boolean | undefined) } - `; function testParsedAndCheckedTransformer(this: PluginTestContext): void { diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/objectlink/objectlink-basic.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/objectlink/objectlink-basic.test.ts index 60707178b77bdc482e570426c2f660f62b3c6f9a..c42ce7782b1ad8e9b08f6990cf76bb38cda08f5b 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/objectlink/objectlink-basic.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/objectlink/objectlink-basic.test.ts @@ -137,9 +137,9 @@ function main() {} } public __updateStruct(initializers: (__Options_MyStateSample | undefined)): void { - if (((({let gensym___97362509 = initializers; - (((gensym___97362509) == (null)) ? undefined : gensym___97362509.objectlinkvar)})) !== (undefined))) { - this.__backing_objectlinkvar!.update(initializers!.objectlinkvar!); + if (({let gensym___71090848 = initializers; + (((gensym___71090848) == (null)) ? undefined : gensym___71090848.__options_has_objectlinkvar)})) { + this.__backing_objectlinkvar!.update((initializers!.objectlinkvar as A)); } } @@ -166,17 +166,17 @@ function main() {} } public __updateStruct(initializers: (__Options_MyStateSample2 | undefined)): void { - if (((({let gensym___82770935 = initializers; - (((gensym___82770935) == (null)) ? undefined : gensym___82770935.objectlinkvar1)})) !== (undefined))) { - this.__backing_objectlinkvar1!.update(initializers!.objectlinkvar1!); + if (({let gensym___180637479 = initializers; + (((gensym___180637479) == (null)) ? undefined : gensym___180637479.__options_has_objectlinkvar1)})) { + this.__backing_objectlinkvar1!.update((initializers!.objectlinkvar1 as (A | undefined))); } - if (((({let gensym___225818999 = initializers; - (((gensym___225818999) == (null)) ? undefined : gensym___225818999.objectlinkvar2)})) !== (undefined))) { - this.__backing_objectlinkvar2!.update(initializers!.objectlinkvar2!); + if (({let gensym___76030692 = initializers; + (((gensym___76030692) == (null)) ? undefined : gensym___76030692.__options_has_objectlinkvar2)})) { + this.__backing_objectlinkvar2!.update((initializers!.objectlinkvar2 as (A | B))); } - if (((({let gensym___3063329 = initializers; - (((gensym___3063329) == (null)) ? undefined : gensym___3063329.objectlinkvar3)})) !== (undefined))) { - this.__backing_objectlinkvar3!.update(initializers!.objectlinkvar3!); + if (({let gensym___49815838 = initializers; + (((gensym___49815838) == (null)) ? undefined : gensym___49815838.__options_has_objectlinkvar3)})) { + this.__backing_objectlinkvar3!.update((initializers!.objectlinkvar3 as (A | B | null))); } } @@ -211,6 +211,9 @@ function main() {} set __backing_objectlinkvar(__backing_objectlinkvar: (IObjectLinkDecoratedVariable | undefined)) get __backing_objectlinkvar(): (IObjectLinkDecoratedVariable | undefined) + set __options_has_objectlinkvar(__options_has_objectlinkvar: (boolean | undefined)) + + get __options_has_objectlinkvar(): (boolean | undefined) } @@ -221,18 +224,27 @@ function main() {} set __backing_objectlinkvar1(__backing_objectlinkvar1: (IObjectLinkDecoratedVariable<(A | undefined)> | undefined)) get __backing_objectlinkvar1(): (IObjectLinkDecoratedVariable<(A | undefined)> | undefined) + set __options_has_objectlinkvar1(__options_has_objectlinkvar1: (boolean | undefined)) + + get __options_has_objectlinkvar1(): (boolean | undefined) set objectlinkvar2(objectlinkvar2: ((A | B) | undefined)) get objectlinkvar2(): ((A | B) | undefined) set __backing_objectlinkvar2(__backing_objectlinkvar2: (IObjectLinkDecoratedVariable<(A | B)> | undefined)) get __backing_objectlinkvar2(): (IObjectLinkDecoratedVariable<(A | B)> | undefined) + set __options_has_objectlinkvar2(__options_has_objectlinkvar2: (boolean | undefined)) + + get __options_has_objectlinkvar2(): (boolean | undefined) set objectlinkvar3(objectlinkvar3: ((A | B | null) | undefined)) get objectlinkvar3(): ((A | B | null) | undefined) set __backing_objectlinkvar3(__backing_objectlinkvar3: (IObjectLinkDecoratedVariable<(A | B | null)> | undefined)) get __backing_objectlinkvar3(): (IObjectLinkDecoratedVariable<(A | B | null)> | undefined) + set __options_has_objectlinkvar3(__options_has_objectlinkvar3: (boolean | undefined)) + + get __options_has_objectlinkvar3(): (boolean | undefined) } `; diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/objectlink/objectlink-observed.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/objectlink/objectlink-observed.test.ts index 640a8e961b595b0705a6194f48f0e016f89843ee..f77a83ae2c98b95468740ee821c7baed7b0ed8b9 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/objectlink/objectlink-observed.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/objectlink/objectlink-observed.test.ts @@ -177,9 +177,9 @@ __EntryWrapper.RegisterNamedRouter("", new __EntryWrapper(), ({ } public __updateStruct(initializers: (__Options_Child | undefined)): void { - if (((({let gensym___232946400 = initializers; - (((gensym___232946400) == (null)) ? undefined : gensym___232946400.data)})) !== (undefined))) { - this.__backing_data!.update(initializers!.data!); + if (({let gensym___237646022 = initializers; + (((gensym___237646022) == (null)) ? undefined : gensym___237646022.__options_has_data)})) { + this.__backing_data!.update((initializers!.data as DateClass)); } } @@ -238,7 +238,9 @@ __EntryWrapper.RegisterNamedRouter("", new __EntryWrapper(), ({ return new Child(); }), { label: "date", + __options_has_label: true, data: this.newData.data, + __options_has_data: true, }, undefined, undefined); Button(@memo() ((instance: ButtonAttribute): void => { instance.onClick(((e: ClickEvent) => { @@ -263,12 +265,18 @@ __EntryWrapper.RegisterNamedRouter("", new __EntryWrapper(), ({ set label(label: (string | undefined)) get label(): (string | undefined) + set __options_has_label(__options_has_label: (boolean | undefined)) + + get __options_has_label(): (boolean | undefined) set data(data: (DateClass | undefined)) get data(): (DateClass | undefined) set __backing_data(__backing_data: (IObjectLinkDecoratedVariable | undefined)) get __backing_data(): (IObjectLinkDecoratedVariable | undefined) + set __options_has_data(__options_has_data: (boolean | undefined)) + + get __options_has_data(): (boolean | undefined) } @@ -279,6 +287,9 @@ __EntryWrapper.RegisterNamedRouter("", new __EntryWrapper(), ({ set __backing_newData(__backing_newData: (IStateDecoratedVariable | undefined)) get __backing_newData(): (IStateDecoratedVariable | undefined) + set __options_has_newData(__options_has_newData: (boolean | undefined)) + + get __options_has_newData(): (boolean | undefined) } diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/once/once-basic-type.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/once/once-basic-type.test.ts index 9b2e68cca511a8e53f8603a9794b02441a9a6cba..7d64b281da57ed667d6fb61d186a3c0b7f2510d1 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/once/once-basic-type.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/once/once-basic-type.test.ts @@ -52,8 +52,6 @@ import { Param as Param, Once as Once } from "@ohos.arkui.stateManagement"; function main() {} - - @ComponentV2() final struct Parent extends CustomComponentV2 { public __initializeStruct(initializers: (__Options_Parent | undefined), @memo() content: ((()=> void) | undefined)): void { this.__backing_onceVar1 = STATE_MGMT_FACTORY.makeParamOnce(this, "onceVar1", ((({let gensym___35048285 = initializers; @@ -133,30 +131,45 @@ function main() {} @Param() set __backing_onceVar1(__backing_onceVar1: (IParamOnceDecoratedVariable | undefined)) @Param() get __backing_onceVar1(): (IParamOnceDecoratedVariable | undefined) + set __options_has_onceVar1(__options_has_onceVar1: (boolean | undefined)) + + get __options_has_onceVar1(): (boolean | undefined) set onceVar2(onceVar2: (number | undefined)) get onceVar2(): (number | undefined) @Param() set __backing_onceVar2(__backing_onceVar2: (IParamOnceDecoratedVariable | undefined)) @Param() get __backing_onceVar2(): (IParamOnceDecoratedVariable | undefined) + set __options_has_onceVar2(__options_has_onceVar2: (boolean | undefined)) + + get __options_has_onceVar2(): (boolean | undefined) set onceVar3(onceVar3: (boolean | undefined)) get onceVar3(): (boolean | undefined) @Param() set __backing_onceVar3(__backing_onceVar3: (IParamOnceDecoratedVariable | undefined)) @Param() get __backing_onceVar3(): (IParamOnceDecoratedVariable | undefined) + set __options_has_onceVar3(__options_has_onceVar3: (boolean | undefined)) + + get __options_has_onceVar3(): (boolean | undefined) set onceVar4(onceVar4: (undefined | undefined)) get onceVar4(): (undefined | undefined) @Param() set __backing_onceVar4(__backing_onceVar4: (IParamOnceDecoratedVariable | undefined)) @Param() get __backing_onceVar4(): (IParamOnceDecoratedVariable | undefined) + set __options_has_onceVar4(__options_has_onceVar4: (boolean | undefined)) + + get __options_has_onceVar4(): (boolean | undefined) set onceVar5(onceVar5: (null | undefined)) get onceVar5(): (null | undefined) @Param() set __backing_onceVar5(__backing_onceVar5: (IParamOnceDecoratedVariable | undefined)) @Param() get __backing_onceVar5(): (IParamOnceDecoratedVariable | undefined) + set __options_has_onceVar5(__options_has_onceVar5: (boolean | undefined)) + + get __options_has_onceVar5(): (boolean | undefined) } `; diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/once/once-complex-type.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/once/once-complex-type.test.ts index e044f9ed1d6b0a309e196ace8da84e83512b4b22..b55accd91e3b4737a3fc77d316f00b16b9d6ff31 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/once/once-complex-type.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/once/once-complex-type.test.ts @@ -131,30 +131,30 @@ final class StateType extends BaseEnum { @ComponentV2() final struct Parent extends CustomComponentV2 { public __initializeStruct(initializers: (__Options_Parent | undefined), @memo() content: ((()=> void) | undefined)): void { - this.__backing_onceVar1 = STATE_MGMT_FACTORY.makeParamOnce(this, "onceVar1", ((({let gensym___35048285 = initializers; - (((gensym___35048285) == (null)) ? undefined : gensym___35048285.onceVar1)})) ?? (new Per(6)))); - this.__backing_onceVar2 = STATE_MGMT_FACTORY.makeParamOnce>(this, "onceVar2", ((({let gensym___241100287 = initializers; - (((gensym___241100287) == (null)) ? undefined : gensym___241100287.onceVar2)})) ?? (new Array(3, 6, 8)))); - this.__backing_onceVar3 = STATE_MGMT_FACTORY.makeParamOnce(this, "onceVar3", ((({let gensym___114153851 = initializers; - (((gensym___114153851) == (null)) ? undefined : gensym___114153851.onceVar3)})) ?? (StateType.TYPE3))); - this.__backing_onceVar4 = STATE_MGMT_FACTORY.makeParamOnce>(this, "onceVar4", ((({let gensym___18636164 = initializers; - (((gensym___18636164) == (null)) ? undefined : gensym___18636164.onceVar4)})) ?? (new Set(new Array("aa", "bb"))))); - this.__backing_onceVar5 = STATE_MGMT_FACTORY.makeParamOnce>(this, "onceVar5", ((({let gensym___60128231 = initializers; - (((gensym___60128231) == (null)) ? undefined : gensym___60128231.onceVar5)})) ?? ([true, false]))); - this.__backing_onceVar6 = STATE_MGMT_FACTORY.makeParamOnce>(this, "onceVar6", ((({let gensym___266500361 = initializers; - (((gensym___266500361) == (null)) ? undefined : gensym___266500361.onceVar6)})) ?? (new Array(new Per(7), new Per(11))))); - this.__backing_onceVar7 = STATE_MGMT_FACTORY.makeParamOnce>(this, "onceVar7", ((({let gensym___265659510 = initializers; - (((gensym___265659510) == (null)) ? undefined : gensym___265659510.onceVar7)})) ?? ([new Per(7), new Per(11)]))); - this.__backing_onceVar8 = STATE_MGMT_FACTORY.makeParamOnce<((sr: string)=> void)>(this, "onceVar8", ((({let gensym___258402603 = initializers; - (((gensym___258402603) == (null)) ? undefined : gensym___258402603.onceVar8)})) ?? (((sr: string) => {})))); - this.__backing_onceVar9 = STATE_MGMT_FACTORY.makeParamOnce(this, "onceVar9", ((({let gensym___90206878 = initializers; - (((gensym___90206878) == (null)) ? undefined : gensym___90206878.onceVar9)})) ?? (new Date("2025-4-23")))); - this.__backing_onceVar10 = STATE_MGMT_FACTORY.makeParamOnce>(this, "onceVar10", ((({let gensym___76706777 = initializers; - (((gensym___76706777) == (null)) ? undefined : gensym___76706777.onceVar10)})) ?? (new Map([[0, new Per(7)], [1, new Per(10)]])))); - this.__backing_onceVar11 = STATE_MGMT_FACTORY.makeParamOnce<(string | number)>(this, "onceVar11", ((({let gensym___188373395 = initializers; - (((gensym___188373395) == (null)) ? undefined : gensym___188373395.onceVar11)})) ?? (0.0))); - this.__backing_onceVar12 = STATE_MGMT_FACTORY.makeParamOnce<(Set | Per)>(this, "onceVar12", ((({let gensym___207702762 = initializers; - (((gensym___207702762) == (null)) ? undefined : gensym___207702762.onceVar12)})) ?? (new Per(6)))); + this.__backing_onceVar1 = STATE_MGMT_FACTORY.makeParamOnce(this, "onceVar1", ((({let gensym___126233468 = initializers; + (((gensym___126233468) == (null)) ? undefined : gensym___126233468.onceVar1)})) ?? (new Per(6)))); + this.__backing_onceVar2 = STATE_MGMT_FACTORY.makeParamOnce>(this, "onceVar2", ((({let gensym___261494487 = initializers; + (((gensym___261494487) == (null)) ? undefined : gensym___261494487.onceVar2)})) ?? (new Array(3, 6, 8)))); + this.__backing_onceVar3 = STATE_MGMT_FACTORY.makeParamOnce(this, "onceVar3", ((({let gensym___200918371 = initializers; + (((gensym___200918371) == (null)) ? undefined : gensym___200918371.onceVar3)})) ?? (StateType.TYPE3))); + this.__backing_onceVar4 = STATE_MGMT_FACTORY.makeParamOnce>(this, "onceVar4", ((({let gensym___220514418 = initializers; + (((gensym___220514418) == (null)) ? undefined : gensym___220514418.onceVar4)})) ?? (new Set(new Array("aa", "bb"))))); + this.__backing_onceVar5 = STATE_MGMT_FACTORY.makeParamOnce>(this, "onceVar5", ((({let gensym___107034111 = initializers; + (((gensym___107034111) == (null)) ? undefined : gensym___107034111.onceVar5)})) ?? ([true, false]))); + this.__backing_onceVar6 = STATE_MGMT_FACTORY.makeParamOnce>(this, "onceVar6", ((({let gensym___174577499 = initializers; + (((gensym___174577499) == (null)) ? undefined : gensym___174577499.onceVar6)})) ?? (new Array(new Per(7), new Per(11))))); + this.__backing_onceVar7 = STATE_MGMT_FACTORY.makeParamOnce>(this, "onceVar7", ((({let gensym___222282406 = initializers; + (((gensym___222282406) == (null)) ? undefined : gensym___222282406.onceVar7)})) ?? ([new Per(7), new Per(11)]))); + this.__backing_onceVar8 = STATE_MGMT_FACTORY.makeParamOnce<((sr: string)=> void)>(this, "onceVar8", ((({let gensym___227003443 = initializers; + (((gensym___227003443) == (null)) ? undefined : gensym___227003443.onceVar8)})) ?? (((sr: string) => {})))); + this.__backing_onceVar9 = STATE_MGMT_FACTORY.makeParamOnce(this, "onceVar9", ((({let gensym___102086008 = initializers; + (((gensym___102086008) == (null)) ? undefined : gensym___102086008.onceVar9)})) ?? (new Date("2025-4-23")))); + this.__backing_onceVar10 = STATE_MGMT_FACTORY.makeParamOnce>(this, "onceVar10", ((({let gensym___97859136 = initializers; + (((gensym___97859136) == (null)) ? undefined : gensym___97859136.onceVar10)})) ?? (new Map([[0, new Per(7)], [1, new Per(10)]])))); + this.__backing_onceVar11 = STATE_MGMT_FACTORY.makeParamOnce<(string | number)>(this, "onceVar11", ((({let gensym___90350745 = initializers; + (((gensym___90350745) == (null)) ? undefined : gensym___90350745.onceVar11)})) ?? (0.0))); + this.__backing_onceVar12 = STATE_MGMT_FACTORY.makeParamOnce<(Set | Per)>(this, "onceVar12", ((({let gensym___96372310 = initializers; + (((gensym___96372310) == (null)) ? undefined : gensym___96372310.onceVar12)})) ?? (new Per(6)))); } public __updateStruct(initializers: (__Options_Parent | undefined)): void {} @@ -292,72 +292,108 @@ final class StateType extends BaseEnum { @Param() set __backing_onceVar1(__backing_onceVar1: (IParamOnceDecoratedVariable | undefined)) @Param() get __backing_onceVar1(): (IParamOnceDecoratedVariable | undefined) + set __options_has_onceVar1(__options_has_onceVar1: (boolean | undefined)) + + get __options_has_onceVar1(): (boolean | undefined) set onceVar2(onceVar2: (Array | undefined)) get onceVar2(): (Array | undefined) @Param() set __backing_onceVar2(__backing_onceVar2: (IParamOnceDecoratedVariable> | undefined)) @Param() get __backing_onceVar2(): (IParamOnceDecoratedVariable> | undefined) + set __options_has_onceVar2(__options_has_onceVar2: (boolean | undefined)) + + get __options_has_onceVar2(): (boolean | undefined) set onceVar3(onceVar3: (StateType | undefined)) get onceVar3(): (StateType | undefined) @Param() set __backing_onceVar3(__backing_onceVar3: (IParamOnceDecoratedVariable | undefined)) @Param() get __backing_onceVar3(): (IParamOnceDecoratedVariable | undefined) + set __options_has_onceVar3(__options_has_onceVar3: (boolean | undefined)) + + get __options_has_onceVar3(): (boolean | undefined) set onceVar4(onceVar4: (Set | undefined)) get onceVar4(): (Set | undefined) @Param() set __backing_onceVar4(__backing_onceVar4: (IParamOnceDecoratedVariable> | undefined)) @Param() get __backing_onceVar4(): (IParamOnceDecoratedVariable> | undefined) + set __options_has_onceVar4(__options_has_onceVar4: (boolean | undefined)) + + get __options_has_onceVar4(): (boolean | undefined) set onceVar5(onceVar5: (Array | undefined)) get onceVar5(): (Array | undefined) @Param() set __backing_onceVar5(__backing_onceVar5: (IParamOnceDecoratedVariable> | undefined)) @Param() get __backing_onceVar5(): (IParamOnceDecoratedVariable> | undefined) + set __options_has_onceVar5(__options_has_onceVar5: (boolean | undefined)) + + get __options_has_onceVar5(): (boolean | undefined) set onceVar6(onceVar6: (Array | undefined)) get onceVar6(): (Array | undefined) @Param() set __backing_onceVar6(__backing_onceVar6: (IParamOnceDecoratedVariable> | undefined)) @Param() get __backing_onceVar6(): (IParamOnceDecoratedVariable> | undefined) + set __options_has_onceVar6(__options_has_onceVar6: (boolean | undefined)) + + get __options_has_onceVar6(): (boolean | undefined) set onceVar7(onceVar7: (Array | undefined)) get onceVar7(): (Array | undefined) @Param() set __backing_onceVar7(__backing_onceVar7: (IParamOnceDecoratedVariable> | undefined)) @Param() get __backing_onceVar7(): (IParamOnceDecoratedVariable> | undefined) + set __options_has_onceVar7(__options_has_onceVar7: (boolean | undefined)) + + get __options_has_onceVar7(): (boolean | undefined) set onceVar8(onceVar8: (((sr: string)=> void) | undefined)) get onceVar8(): (((sr: string)=> void) | undefined) @Param() set __backing_onceVar8(__backing_onceVar8: (IParamOnceDecoratedVariable<((sr: string)=> void)> | undefined)) @Param() get __backing_onceVar8(): (IParamOnceDecoratedVariable<((sr: string)=> void)> | undefined) + set __options_has_onceVar8(__options_has_onceVar8: (boolean | undefined)) + + get __options_has_onceVar8(): (boolean | undefined) set onceVar9(onceVar9: (Date | undefined)) get onceVar9(): (Date | undefined) @Param() set __backing_onceVar9(__backing_onceVar9: (IParamOnceDecoratedVariable | undefined)) @Param() get __backing_onceVar9(): (IParamOnceDecoratedVariable | undefined) + set __options_has_onceVar9(__options_has_onceVar9: (boolean | undefined)) + + get __options_has_onceVar9(): (boolean | undefined) set onceVar10(onceVar10: (Map | undefined)) get onceVar10(): (Map | undefined) @Param() set __backing_onceVar10(__backing_onceVar10: (IParamOnceDecoratedVariable> | undefined)) @Param() get __backing_onceVar10(): (IParamOnceDecoratedVariable> | undefined) + set __options_has_onceVar10(__options_has_onceVar10: (boolean | undefined)) + + get __options_has_onceVar10(): (boolean | undefined) set onceVar11(onceVar11: ((string | number) | undefined)) get onceVar11(): ((string | number) | undefined) @Param() set __backing_onceVar11(__backing_onceVar11: (IParamOnceDecoratedVariable<(string | number)> | undefined)) @Param() get __backing_onceVar11(): (IParamOnceDecoratedVariable<(string | number)> | undefined) + set __options_has_onceVar11(__options_has_onceVar11: (boolean | undefined)) + + get __options_has_onceVar11(): (boolean | undefined) set onceVar12(onceVar12: ((Set | Per) | undefined)) get onceVar12(): ((Set | Per) | undefined) @Param() set __backing_onceVar12(__backing_onceVar12: (IParamOnceDecoratedVariable<(Set | Per)> | undefined)) @Param() get __backing_onceVar12(): (IParamOnceDecoratedVariable<(Set | Per)> | undefined) + set __options_has_onceVar12(__options_has_onceVar12: (boolean | undefined)) + + get __options_has_onceVar12(): (boolean | undefined) } `; diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/once/once-only.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/once/once-only.test.ts index db04b7b652004f4aaf63e51d0c3ae4466c84251d..a4b807d9a663197f9bb079f25423728223bc4832 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/once/once-only.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/once/once-only.test.ts @@ -90,12 +90,18 @@ function main() {} set __backing_onceParamNum(__backing_onceParamNum: (IParamOnceDecoratedVariable | undefined)) get __backing_onceParamNum(): (IParamOnceDecoratedVariable | undefined) + set __options_has_onceParamNum(__options_has_onceParamNum: (boolean | undefined)) + + get __options_has_onceParamNum(): (boolean | undefined) set onceVar4(onceVar4: (Set | undefined)) get onceVar4(): (Set | undefined) set __backing_onceVar4(__backing_onceVar4: (IParamOnceDecoratedVariable> | undefined)) get __backing_onceVar4(): (IParamOnceDecoratedVariable> | undefined) + set __options_has_onceVar4(__options_has_onceVar4: (boolean | undefined)) + + get __options_has_onceVar4(): (boolean | undefined) } `; diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/once/once-with-require.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/once/once-with-require.test.ts index 9dee701f476bbabd59ea7bdcaa52e603e7748f73..02580bbd2fb7f61aa5339c23c5e8de52f357da5c 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/once/once-with-require.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/once/once-with-require.test.ts @@ -93,16 +93,20 @@ import { Param as Param, Once as Once, ObservedV2 as ObservedV2, Trace as Trace, @ComponentV2() export interface __Options_Child { onceParamNum?: number; @Param() @Once() __backing_onceParamNum?: number; + __options_has_onceParamNum?: boolean; onceParamInfo?: Info; @Param() @Once() @Require() __backing_onceParamInfo?: Info; + __options_has_onceParamInfo?: boolean; } @ComponentV2() export interface __Options_Index { localNum?: number; @Local() __backing_localNum?: number; + __options_has_localNum?: boolean; localInfo?: Info; @Local() __backing_localInfo?: Info; + __options_has_localInfo?: boolean; } `; @@ -264,7 +268,9 @@ function main() {} return new Child(); }), { onceParamNum: this.localNum, + __options_has_onceParamNum: true, onceParamInfo: this.localInfo, + __options_has_onceParamInfo: true, }, undefined, undefined); })); } @@ -280,12 +286,18 @@ function main() {} @Param() set __backing_onceParamNum(__backing_onceParamNum: (IParamOnceDecoratedVariable | undefined)) @Param() get __backing_onceParamNum(): (IParamOnceDecoratedVariable | undefined) + set __options_has_onceParamNum(__options_has_onceParamNum: (boolean | undefined)) + + get __options_has_onceParamNum(): (boolean | undefined) set onceParamInfo(onceParamInfo: (Info | undefined)) get onceParamInfo(): (Info | undefined) @Param() @Require() set __backing_onceParamInfo(__backing_onceParamInfo: (IParamOnceDecoratedVariable | undefined)) @Param() @Require() get __backing_onceParamInfo(): (IParamOnceDecoratedVariable | undefined) + set __options_has_onceParamInfo(__options_has_onceParamInfo: (boolean | undefined)) + + get __options_has_onceParamInfo(): (boolean | undefined) } @@ -296,12 +308,18 @@ function main() {} set __backing_localNum(__backing_localNum: (ILocalDecoratedVariable | undefined)) get __backing_localNum(): (ILocalDecoratedVariable | undefined) + set __options_has_localNum(__options_has_localNum: (boolean | undefined)) + + get __options_has_localNum(): (boolean | undefined) set localInfo(localInfo: (Info | undefined)) get localInfo(): (Info | undefined) set __backing_localInfo(__backing_localInfo: (ILocalDecoratedVariable | undefined)) get __backing_localInfo(): (ILocalDecoratedVariable | undefined) + set __options_has_localInfo(__options_has_localInfo: (boolean | undefined)) + + get __options_has_localInfo(): (boolean | undefined) } `; diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/param/param-basic-type.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/param/param-basic-type.test.ts index c02112576e43d7a643f5bd999cca5e60617b87be..bc80b1e39545f7b9e6a04bb8f77ad08058fe623a 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/param/param-basic-type.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/param/param-basic-type.test.ts @@ -67,24 +67,24 @@ function main() {} } public __updateStruct(initializers: (__Options_Parent | undefined)): void { - if (((({let gensym___99629634 = initializers; - (((gensym___99629634) == (null)) ? undefined : gensym___99629634.paramVar1)})) !== (undefined))) { + if (({let gensym___160055409 = initializers; + (((gensym___160055409) == (null)) ? undefined : gensym___160055409.__options_has_paramVar1)})) { this.__backing_paramVar1!.update((initializers!.paramVar1 as string)); } - if (((({let gensym___68516859 = initializers; - (((gensym___68516859) == (null)) ? undefined : gensym___68516859.paramVar2)})) !== (undefined))) { + if (({let gensym___2437677 = initializers; + (((gensym___2437677) == (null)) ? undefined : gensym___2437677.__options_has_paramVar2)})) { this.__backing_paramVar2!.update((initializers!.paramVar2 as number)); } - if (((({let gensym___96937083 = initializers; - (((gensym___96937083) == (null)) ? undefined : gensym___96937083.paramVar3)})) !== (undefined))) { + if (({let gensym___113817398 = initializers; + (((gensym___113817398) == (null)) ? undefined : gensym___113817398.__options_has_paramVar3)})) { this.__backing_paramVar3!.update((initializers!.paramVar3 as boolean)); } - if (((({let gensym___151087626 = initializers; - (((gensym___151087626) == (null)) ? undefined : gensym___151087626.paramVar4)})) !== (undefined))) { + if (({let gensym___69812855 = initializers; + (((gensym___69812855) == (null)) ? undefined : gensym___69812855.__options_has_paramVar4)})) { this.__backing_paramVar4!.update((initializers!.paramVar4 as undefined)); } - if (((({let gensym___127163363 = initializers; - (((gensym___127163363) == (null)) ? undefined : gensym___127163363.paramVar5)})) !== (undefined))) { + if (({let gensym___184913887 = initializers; + (((gensym___184913887) == (null)) ? undefined : gensym___184913887.__options_has_paramVar5)})) { this.__backing_paramVar5!.update((initializers!.paramVar5 as null)); } } @@ -132,30 +132,45 @@ function main() {} set __backing_paramVar1(__backing_paramVar1: (IParamDecoratedVariable | undefined)) get __backing_paramVar1(): (IParamDecoratedVariable | undefined) + set __options_has_paramVar1(__options_has_paramVar1: (boolean | undefined)) + + get __options_has_paramVar1(): (boolean | undefined) set paramVar2(paramVar2: (number | undefined)) get paramVar2(): (number | undefined) set __backing_paramVar2(__backing_paramVar2: (IParamDecoratedVariable | undefined)) get __backing_paramVar2(): (IParamDecoratedVariable | undefined) + set __options_has_paramVar2(__options_has_paramVar2: (boolean | undefined)) + + get __options_has_paramVar2(): (boolean | undefined) set paramVar3(paramVar3: (boolean | undefined)) get paramVar3(): (boolean | undefined) set __backing_paramVar3(__backing_paramVar3: (IParamDecoratedVariable | undefined)) get __backing_paramVar3(): (IParamDecoratedVariable | undefined) + set __options_has_paramVar3(__options_has_paramVar3: (boolean | undefined)) + + get __options_has_paramVar3(): (boolean | undefined) set paramVar4(paramVar4: (undefined | undefined)) get paramVar4(): (undefined | undefined) set __backing_paramVar4(__backing_paramVar4: (IParamDecoratedVariable | undefined)) get __backing_paramVar4(): (IParamDecoratedVariable | undefined) + set __options_has_paramVar4(__options_has_paramVar4: (boolean | undefined)) + + get __options_has_paramVar4(): (boolean | undefined) set paramVar5(paramVar5: (null | undefined)) get paramVar5(): (null | undefined) set __backing_paramVar5(__backing_paramVar5: (IParamDecoratedVariable | undefined)) get __backing_paramVar5(): (IParamDecoratedVariable | undefined) + set __options_has_paramVar5(__options_has_paramVar5: (boolean | undefined)) + + get __options_has_paramVar5(): (boolean | undefined) } `; diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/param/param-complex-type.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/param/param-complex-type.test.ts index 3639b125344f3716fc557533668f6dafb7d1a3e3..8bb1816401c1fce6a9eccfb007fc00622eb82fba 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/param/param-complex-type.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/param/param-complex-type.test.ts @@ -52,8 +52,6 @@ import { Param as Param } from "@ohos.arkui.stateManagement"; function main() {} - - class Per { public num: number; @@ -160,52 +158,52 @@ final class StateType extends BaseEnum { } public __updateStruct(initializers: (__Options_Parent | undefined)): void { - if (((({let gensym___99629634 = initializers; - (((gensym___99629634) == (null)) ? undefined : gensym___99629634.paramVar1)})) !== (undefined))) { + if (({let gensym___160055409 = initializers; + (((gensym___160055409) == (null)) ? undefined : gensym___160055409.__options_has_paramVar1)})) { this.__backing_paramVar1!.update((initializers!.paramVar1 as Per)); } - if (((({let gensym___68516859 = initializers; - (((gensym___68516859) == (null)) ? undefined : gensym___68516859.paramVar2)})) !== (undefined))) { + if (({let gensym___2437677 = initializers; + (((gensym___2437677) == (null)) ? undefined : gensym___2437677.__options_has_paramVar2)})) { this.__backing_paramVar2!.update((initializers!.paramVar2 as Array)); } - if (((({let gensym___96937083 = initializers; - (((gensym___96937083) == (null)) ? undefined : gensym___96937083.paramVar3)})) !== (undefined))) { + if (({let gensym___113817398 = initializers; + (((gensym___113817398) == (null)) ? undefined : gensym___113817398.__options_has_paramVar3)})) { this.__backing_paramVar3!.update((initializers!.paramVar3 as StateType)); } - if (((({let gensym___151087626 = initializers; - (((gensym___151087626) == (null)) ? undefined : gensym___151087626.paramVar4)})) !== (undefined))) { + if (({let gensym___69812855 = initializers; + (((gensym___69812855) == (null)) ? undefined : gensym___69812855.__options_has_paramVar4)})) { this.__backing_paramVar4!.update((initializers!.paramVar4 as Set)); } - if (((({let gensym___127163363 = initializers; - (((gensym___127163363) == (null)) ? undefined : gensym___127163363.paramVar5)})) !== (undefined))) { + if (({let gensym___184913887 = initializers; + (((gensym___184913887) == (null)) ? undefined : gensym___184913887.__options_has_paramVar5)})) { this.__backing_paramVar5!.update((initializers!.paramVar5 as Array)); } - if (((({let gensym___67758341 = initializers; - (((gensym___67758341) == (null)) ? undefined : gensym___67758341.paramVar6)})) !== (undefined))) { + if (({let gensym___22345724 = initializers; + (((gensym___22345724) == (null)) ? undefined : gensym___22345724.__options_has_paramVar6)})) { this.__backing_paramVar6!.update((initializers!.paramVar6 as Array)); } - if (((({let gensym___248313276 = initializers; - (((gensym___248313276) == (null)) ? undefined : gensym___248313276.paramVar7)})) !== (undefined))) { + if (({let gensym___35909170 = initializers; + (((gensym___35909170) == (null)) ? undefined : gensym___35909170.__options_has_paramVar7)})) { this.__backing_paramVar7!.update((initializers!.paramVar7 as Array)); } - if (((({let gensym___215432014 = initializers; - (((gensym___215432014) == (null)) ? undefined : gensym___215432014.paramVar8)})) !== (undefined))) { + if (({let gensym___221406315 = initializers; + (((gensym___221406315) == (null)) ? undefined : gensym___221406315.__options_has_paramVar8)})) { this.__backing_paramVar8!.update((initializers!.paramVar8 as ((sr: string)=> void))); } - if (((({let gensym___69570417 = initializers; - (((gensym___69570417) == (null)) ? undefined : gensym___69570417.paramVar9)})) !== (undefined))) { + if (({let gensym___76379892 = initializers; + (((gensym___76379892) == (null)) ? undefined : gensym___76379892.__options_has_paramVar9)})) { this.__backing_paramVar9!.update((initializers!.paramVar9 as Date)); } - if (((({let gensym___121882834 = initializers; - (((gensym___121882834) == (null)) ? undefined : gensym___121882834.paramVar10)})) !== (undefined))) { + if (({let gensym___223285288 = initializers; + (((gensym___223285288) == (null)) ? undefined : gensym___223285288.__options_has_paramVar10)})) { this.__backing_paramVar10!.update((initializers!.paramVar10 as Map)); } - if (((({let gensym___56641620 = initializers; - (((gensym___56641620) == (null)) ? undefined : gensym___56641620.paramVar11)})) !== (undefined))) { + if (({let gensym___34579549 = initializers; + (((gensym___34579549) == (null)) ? undefined : gensym___34579549.__options_has_paramVar11)})) { this.__backing_paramVar11!.update((initializers!.paramVar11 as (string | number))); } - if (((({let gensym___51325313 = initializers; - (((gensym___51325313) == (null)) ? undefined : gensym___51325313.paramVar12)})) !== (undefined))) { + if (({let gensym___181593007 = initializers; + (((gensym___181593007) == (null)) ? undefined : gensym___181593007.__options_has_paramVar12)})) { this.__backing_paramVar12!.update((initializers!.paramVar12 as (Set | Per))); } } @@ -295,72 +293,108 @@ final class StateType extends BaseEnum { set __backing_paramVar1(__backing_paramVar1: (IParamDecoratedVariable | undefined)) get __backing_paramVar1(): (IParamDecoratedVariable | undefined) + set __options_has_paramVar1(__options_has_paramVar1: (boolean | undefined)) + + get __options_has_paramVar1(): (boolean | undefined) set paramVar2(paramVar2: (Array | undefined)) get paramVar2(): (Array | undefined) set __backing_paramVar2(__backing_paramVar2: (IParamDecoratedVariable> | undefined)) get __backing_paramVar2(): (IParamDecoratedVariable> | undefined) + set __options_has_paramVar2(__options_has_paramVar2: (boolean | undefined)) + + get __options_has_paramVar2(): (boolean | undefined) set paramVar3(paramVar3: (StateType | undefined)) get paramVar3(): (StateType | undefined) set __backing_paramVar3(__backing_paramVar3: (IParamDecoratedVariable | undefined)) get __backing_paramVar3(): (IParamDecoratedVariable | undefined) + set __options_has_paramVar3(__options_has_paramVar3: (boolean | undefined)) + + get __options_has_paramVar3(): (boolean | undefined) set paramVar4(paramVar4: (Set | undefined)) get paramVar4(): (Set | undefined) set __backing_paramVar4(__backing_paramVar4: (IParamDecoratedVariable> | undefined)) get __backing_paramVar4(): (IParamDecoratedVariable> | undefined) + set __options_has_paramVar4(__options_has_paramVar4: (boolean | undefined)) + + get __options_has_paramVar4(): (boolean | undefined) set paramVar5(paramVar5: (Array | undefined)) get paramVar5(): (Array | undefined) set __backing_paramVar5(__backing_paramVar5: (IParamDecoratedVariable> | undefined)) get __backing_paramVar5(): (IParamDecoratedVariable> | undefined) + set __options_has_paramVar5(__options_has_paramVar5: (boolean | undefined)) + + get __options_has_paramVar5(): (boolean | undefined) set paramVar6(paramVar6: (Array | undefined)) get paramVar6(): (Array | undefined) set __backing_paramVar6(__backing_paramVar6: (IParamDecoratedVariable> | undefined)) get __backing_paramVar6(): (IParamDecoratedVariable> | undefined) + set __options_has_paramVar6(__options_has_paramVar6: (boolean | undefined)) + + get __options_has_paramVar6(): (boolean | undefined) set paramVar7(paramVar7: (Array | undefined)) get paramVar7(): (Array | undefined) set __backing_paramVar7(__backing_paramVar7: (IParamDecoratedVariable> | undefined)) get __backing_paramVar7(): (IParamDecoratedVariable> | undefined) + set __options_has_paramVar7(__options_has_paramVar7: (boolean | undefined)) + + get __options_has_paramVar7(): (boolean | undefined) set paramVar8(paramVar8: (((sr: string)=> void) | undefined)) get paramVar8(): (((sr: string)=> void) | undefined) set __backing_paramVar8(__backing_paramVar8: (IParamDecoratedVariable<((sr: string)=> void)> | undefined)) get __backing_paramVar8(): (IParamDecoratedVariable<((sr: string)=> void)> | undefined) + set __options_has_paramVar8(__options_has_paramVar8: (boolean | undefined)) + + get __options_has_paramVar8(): (boolean | undefined) set paramVar9(paramVar9: (Date | undefined)) get paramVar9(): (Date | undefined) set __backing_paramVar9(__backing_paramVar9: (IParamDecoratedVariable | undefined)) get __backing_paramVar9(): (IParamDecoratedVariable | undefined) + set __options_has_paramVar9(__options_has_paramVar9: (boolean | undefined)) + + get __options_has_paramVar9(): (boolean | undefined) set paramVar10(paramVar10: (Map | undefined)) get paramVar10(): (Map | undefined) set __backing_paramVar10(__backing_paramVar10: (IParamDecoratedVariable> | undefined)) get __backing_paramVar10(): (IParamDecoratedVariable> | undefined) + set __options_has_paramVar10(__options_has_paramVar10: (boolean | undefined)) + + get __options_has_paramVar10(): (boolean | undefined) set paramVar11(paramVar11: ((string | number) | undefined)) get paramVar11(): ((string | number) | undefined) set __backing_paramVar11(__backing_paramVar11: (IParamDecoratedVariable<(string | number)> | undefined)) get __backing_paramVar11(): (IParamDecoratedVariable<(string | number)> | undefined) + set __options_has_paramVar11(__options_has_paramVar11: (boolean | undefined)) + + get __options_has_paramVar11(): (boolean | undefined) set paramVar12(paramVar12: ((Set | Per) | undefined)) get paramVar12(): ((Set | Per) | undefined) set __backing_paramVar12(__backing_paramVar12: (IParamDecoratedVariable<(Set | Per)> | undefined)) get __backing_paramVar12(): (IParamDecoratedVariable<(Set | Per)> | undefined) + set __options_has_paramVar12(__options_has_paramVar12: (boolean | undefined)) + + get __options_has_paramVar12(): (boolean | undefined) } `; diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/param/param-with-require.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/param/param-with-require.test.ts index 3ea06e80ed76fe1c6470f11a10fab775f53ffc63..028560ba5554d72f26776b22cb2633b3d4c2dcbd 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/param/param-with-require.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/param/param-with-require.test.ts @@ -126,18 +126,21 @@ class Info { @ComponentV2() export interface __Options_Index { infoList?: Info[]; @Local() __backing_infoList?: Info[]; + __options_has_infoList?: boolean; } @ComponentV2() export interface __Options_MiddleComponent { info?: Info; @Require() @Param() __backing_info?: Info; + __options_has_info?: boolean; } @ComponentV2() export interface __Options_SubComponent { region?: Region; @Require() @Param() __backing_region?: Region; + __options_has_region?: boolean; } `; @@ -216,6 +219,7 @@ class Info { return new MiddleComponent(); }), { info: info, + __options_has_info: true, }, undefined, undefined); })); Button(@memo() ((instance: ButtonAttribute): void => { @@ -239,8 +243,8 @@ class Info { } public __updateStruct(initializers: (__Options_MiddleComponent | undefined)): void { - if (((({let gensym___152615498 = initializers; - (((gensym___152615498) == (null)) ? undefined : gensym___152615498.info)})) !== (undefined))) { + if (({let gensym___20494961 = initializers; + (((gensym___20494961) == (null)) ? undefined : gensym___20494961.__options_has_info)})) { this.__backing_info!.update((initializers!.info as Info)); } } @@ -259,6 +263,7 @@ class Info { return new SubComponent(); }), { region: this.info.region, + __options_has_region: true, }, undefined, undefined); })); } @@ -273,8 +278,8 @@ class Info { } public __updateStruct(initializers: (__Options_SubComponent | undefined)): void { - if (((({let gensym___240509478 = initializers; - (((gensym___240509478) == (null)) ? undefined : gensym___240509478.region)})) !== (undefined))) { + if (({let gensym___4614499 = initializers; + (((gensym___4614499) == (null)) ? undefined : gensym___4614499.__options_has_region)})) { this.__backing_region!.update((initializers!.region as Region)); } } @@ -302,6 +307,9 @@ class Info { set __backing_infoList(__backing_infoList: (ILocalDecoratedVariable> | undefined)) get __backing_infoList(): (ILocalDecoratedVariable> | undefined) + set __options_has_infoList(__options_has_infoList: (boolean | undefined)) + + get __options_has_infoList(): (boolean | undefined) } @@ -312,6 +320,9 @@ class Info { @Require() set __backing_info(__backing_info: (IParamDecoratedVariable | undefined)) @Require() get __backing_info(): (IParamDecoratedVariable | undefined) + set __options_has_info(__options_has_info: (boolean | undefined)) + + get __options_has_info(): (boolean | undefined) } @@ -322,6 +333,9 @@ class Info { @Require() set __backing_region(__backing_region: (IParamDecoratedVariable | undefined)) @Require() get __backing_region(): (IParamDecoratedVariable | undefined) + set __options_has_region(__options_has_region: (boolean | undefined)) + + get __options_has_region(): (boolean | undefined) } `; diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/prop-ref/prop-ref-basic-type.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/prop-ref/prop-ref-basic-type.test.ts index e3b5e8f98bcd314703632ed433700712b5fea6d3..b4f07a481602ad0fd263dfc15307717ece8ec20f 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/prop-ref/prop-ref-basic-type.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/prop-ref/prop-ref-basic-type.test.ts @@ -69,24 +69,24 @@ function main() {} } public __updateStruct(initializers: (__Options_PropParent | undefined)): void { - if (((({let gensym___67969738 = initializers; - (((gensym___67969738) == (null)) ? undefined : gensym___67969738.propVar1)})) !== (undefined))) { + if (({let gensym___222986222 = initializers; + (((gensym___222986222) == (null)) ? undefined : gensym___222986222.__options_has_propVar1)})) { this.__backing_propVar1!.update((initializers!.propVar1 as string)); } - if (((({let gensym___52350476 = initializers; - (((gensym___52350476) == (null)) ? undefined : gensym___52350476.propVar2)})) !== (undefined))) { + if (({let gensym___178023537 = initializers; + (((gensym___178023537) == (null)) ? undefined : gensym___178023537.__options_has_propVar2)})) { this.__backing_propVar2!.update((initializers!.propVar2 as number)); } - if (((({let gensym___103864283 = initializers; - (((gensym___103864283) == (null)) ? undefined : gensym___103864283.propVar3)})) !== (undefined))) { + if (({let gensym___221361445 = initializers; + (((gensym___221361445) == (null)) ? undefined : gensym___221361445.__options_has_propVar3)})) { this.__backing_propVar3!.update((initializers!.propVar3 as boolean)); } - if (((({let gensym___175155715 = initializers; - (((gensym___175155715) == (null)) ? undefined : gensym___175155715.propVar4)})) !== (undefined))) { + if (({let gensym___22732558 = initializers; + (((gensym___22732558) == (null)) ? undefined : gensym___22732558.__options_has_propVar4)})) { this.__backing_propVar4!.update((initializers!.propVar4 as undefined)); } - if (((({let gensym___134530703 = initializers; - (((gensym___134530703) == (null)) ? undefined : gensym___134530703.propVar5)})) !== (undefined))) { + if (({let gensym___143875977 = initializers; + (((gensym___143875977) == (null)) ? undefined : gensym___143875977.__options_has_propVar5)})) { this.__backing_propVar5!.update((initializers!.propVar5 as null)); } } @@ -154,30 +154,45 @@ function main() {} set __backing_propVar1(__backing_propVar1: (IPropRefDecoratedVariable | undefined)) get __backing_propVar1(): (IPropRefDecoratedVariable | undefined) + set __options_has_propVar1(__options_has_propVar1: (boolean | undefined)) + + get __options_has_propVar1(): (boolean | undefined) set propVar2(propVar2: (number | undefined)) get propVar2(): (number | undefined) set __backing_propVar2(__backing_propVar2: (IPropRefDecoratedVariable | undefined)) get __backing_propVar2(): (IPropRefDecoratedVariable | undefined) + set __options_has_propVar2(__options_has_propVar2: (boolean | undefined)) + + get __options_has_propVar2(): (boolean | undefined) set propVar3(propVar3: (boolean | undefined)) get propVar3(): (boolean | undefined) set __backing_propVar3(__backing_propVar3: (IPropRefDecoratedVariable | undefined)) get __backing_propVar3(): (IPropRefDecoratedVariable | undefined) + set __options_has_propVar3(__options_has_propVar3: (boolean | undefined)) + + get __options_has_propVar3(): (boolean | undefined) set propVar4(propVar4: (undefined | undefined)) get propVar4(): (undefined | undefined) set __backing_propVar4(__backing_propVar4: (IPropRefDecoratedVariable | undefined)) get __backing_propVar4(): (IPropRefDecoratedVariable | undefined) + set __options_has_propVar4(__options_has_propVar4: (boolean | undefined)) + + get __options_has_propVar4(): (boolean | undefined) set propVar5(propVar5: (null | undefined)) get propVar5(): (null | undefined) set __backing_propVar5(__backing_propVar5: (IPropRefDecoratedVariable | undefined)) get __backing_propVar5(): (IPropRefDecoratedVariable | undefined) + set __options_has_propVar5(__options_has_propVar5: (boolean | undefined)) + + get __options_has_propVar5(): (boolean | undefined) } `; diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/prop-ref/prop-ref-complex-type.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/prop-ref/prop-ref-complex-type.test.ts index 8dbc549f546a17c785299f5429fe65e05148ae7f..90dcb9280cf5300fb3ec4126cce3ba6c66df5415 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/prop-ref/prop-ref-complex-type.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/prop-ref/prop-ref-complex-type.test.ts @@ -158,52 +158,52 @@ final class PropType extends BaseEnum { } public __updateStruct(initializers: (__Options_Parent | undefined)): void { - if (((({let gensym___67969738 = initializers; - (((gensym___67969738) == (null)) ? undefined : gensym___67969738.propVar1)})) !== (undefined))) { + if (({let gensym___222986222 = initializers; + (((gensym___222986222) == (null)) ? undefined : gensym___222986222.__options_has_propVar1)})) { this.__backing_propVar1!.update((initializers!.propVar1 as Per)); } - if (((({let gensym___52350476 = initializers; - (((gensym___52350476) == (null)) ? undefined : gensym___52350476.propVar2)})) !== (undefined))) { + if (({let gensym___178023537 = initializers; + (((gensym___178023537) == (null)) ? undefined : gensym___178023537.__options_has_propVar2)})) { this.__backing_propVar2!.update((initializers!.propVar2 as Array)); } - if (((({let gensym___103864283 = initializers; - (((gensym___103864283) == (null)) ? undefined : gensym___103864283.propVar3)})) !== (undefined))) { + if (({let gensym___221361445 = initializers; + (((gensym___221361445) == (null)) ? undefined : gensym___221361445.__options_has_propVar3)})) { this.__backing_propVar3!.update((initializers!.propVar3 as PropType)); } - if (((({let gensym___175155715 = initializers; - (((gensym___175155715) == (null)) ? undefined : gensym___175155715.propVar4)})) !== (undefined))) { + if (({let gensym___22732558 = initializers; + (((gensym___22732558) == (null)) ? undefined : gensym___22732558.__options_has_propVar4)})) { this.__backing_propVar4!.update((initializers!.propVar4 as Set)); } - if (((({let gensym___134530703 = initializers; - (((gensym___134530703) == (null)) ? undefined : gensym___134530703.propVar5)})) !== (undefined))) { + if (({let gensym___143875977 = initializers; + (((gensym___143875977) == (null)) ? undefined : gensym___143875977.__options_has_propVar5)})) { this.__backing_propVar5!.update((initializers!.propVar5 as Array)); } - if (((({let gensym___211600890 = initializers; - (((gensym___211600890) == (null)) ? undefined : gensym___211600890.propVar6)})) !== (undefined))) { + if (({let gensym___21159249 = initializers; + (((gensym___21159249) == (null)) ? undefined : gensym___21159249.__options_has_propVar6)})) { this.__backing_propVar6!.update((initializers!.propVar6 as Array)); } - if (((({let gensym___124229427 = initializers; - (((gensym___124229427) == (null)) ? undefined : gensym___124229427.propVar7)})) !== (undefined))) { + if (({let gensym___198355044 = initializers; + (((gensym___198355044) == (null)) ? undefined : gensym___198355044.__options_has_propVar7)})) { this.__backing_propVar7!.update((initializers!.propVar7 as Array)); } - if (((({let gensym___248056380 = initializers; - (((gensym___248056380) == (null)) ? undefined : gensym___248056380.propVar8)})) !== (undefined))) { + if (({let gensym___52710109 = initializers; + (((gensym___52710109) == (null)) ? undefined : gensym___52710109.__options_has_propVar8)})) { this.__backing_propVar8!.update((initializers!.propVar8 as ((sr: string)=> void))); } - if (((({let gensym___55399278 = initializers; - (((gensym___55399278) == (null)) ? undefined : gensym___55399278.propVar9)})) !== (undefined))) { + if (({let gensym___202931084 = initializers; + (((gensym___202931084) == (null)) ? undefined : gensym___202931084.__options_has_propVar9)})) { this.__backing_propVar9!.update((initializers!.propVar9 as Date)); } - if (((({let gensym___125042885 = initializers; - (((gensym___125042885) == (null)) ? undefined : gensym___125042885.propVar10)})) !== (undefined))) { + if (({let gensym___211158796 = initializers; + (((gensym___211158796) == (null)) ? undefined : gensym___211158796.__options_has_propVar10)})) { this.__backing_propVar10!.update((initializers!.propVar10 as Map)); } - if (((({let gensym___2015283 = initializers; - (((gensym___2015283) == (null)) ? undefined : gensym___2015283.propVar11)})) !== (undefined))) { + if (({let gensym___109526633 = initializers; + (((gensym___109526633) == (null)) ? undefined : gensym___109526633.__options_has_propVar11)})) { this.__backing_propVar11!.update((initializers!.propVar11 as (string | number))); } - if (((({let gensym___39009414 = initializers; - (((gensym___39009414) == (null)) ? undefined : gensym___39009414.propVar12)})) !== (undefined))) { + if (({let gensym___33495086 = initializers; + (((gensym___33495086) == (null)) ? undefined : gensym___33495086.__options_has_propVar12)})) { this.__backing_propVar12!.update((initializers!.propVar12 as (Set | Per))); } } @@ -341,72 +341,108 @@ final class PropType extends BaseEnum { set __backing_propVar1(__backing_propVar1: (IPropRefDecoratedVariable | undefined)) get __backing_propVar1(): (IPropRefDecoratedVariable | undefined) + set __options_has_propVar1(__options_has_propVar1: (boolean | undefined)) + + get __options_has_propVar1(): (boolean | undefined) set propVar2(propVar2: (Array | undefined)) get propVar2(): (Array | undefined) set __backing_propVar2(__backing_propVar2: (IPropRefDecoratedVariable> | undefined)) get __backing_propVar2(): (IPropRefDecoratedVariable> | undefined) + set __options_has_propVar2(__options_has_propVar2: (boolean | undefined)) + + get __options_has_propVar2(): (boolean | undefined) set propVar3(propVar3: (PropType | undefined)) get propVar3(): (PropType | undefined) set __backing_propVar3(__backing_propVar3: (IPropRefDecoratedVariable | undefined)) get __backing_propVar3(): (IPropRefDecoratedVariable | undefined) + set __options_has_propVar3(__options_has_propVar3: (boolean | undefined)) + + get __options_has_propVar3(): (boolean | undefined) set propVar4(propVar4: (Set | undefined)) get propVar4(): (Set | undefined) set __backing_propVar4(__backing_propVar4: (IPropRefDecoratedVariable> | undefined)) get __backing_propVar4(): (IPropRefDecoratedVariable> | undefined) + set __options_has_propVar4(__options_has_propVar4: (boolean | undefined)) + + get __options_has_propVar4(): (boolean | undefined) set propVar5(propVar5: (Array | undefined)) get propVar5(): (Array | undefined) set __backing_propVar5(__backing_propVar5: (IPropRefDecoratedVariable> | undefined)) get __backing_propVar5(): (IPropRefDecoratedVariable> | undefined) + set __options_has_propVar5(__options_has_propVar5: (boolean | undefined)) + + get __options_has_propVar5(): (boolean | undefined) set propVar6(propVar6: (Array | undefined)) get propVar6(): (Array | undefined) set __backing_propVar6(__backing_propVar6: (IPropRefDecoratedVariable> | undefined)) get __backing_propVar6(): (IPropRefDecoratedVariable> | undefined) + set __options_has_propVar6(__options_has_propVar6: (boolean | undefined)) + + get __options_has_propVar6(): (boolean | undefined) set propVar7(propVar7: (Array | undefined)) get propVar7(): (Array | undefined) set __backing_propVar7(__backing_propVar7: (IPropRefDecoratedVariable> | undefined)) get __backing_propVar7(): (IPropRefDecoratedVariable> | undefined) + set __options_has_propVar7(__options_has_propVar7: (boolean | undefined)) + + get __options_has_propVar7(): (boolean | undefined) set propVar8(propVar8: (((sr: string)=> void) | undefined)) get propVar8(): (((sr: string)=> void) | undefined) set __backing_propVar8(__backing_propVar8: (IPropRefDecoratedVariable<((sr: string)=> void)> | undefined)) get __backing_propVar8(): (IPropRefDecoratedVariable<((sr: string)=> void)> | undefined) + set __options_has_propVar8(__options_has_propVar8: (boolean | undefined)) + + get __options_has_propVar8(): (boolean | undefined) set propVar9(propVar9: (Date | undefined)) get propVar9(): (Date | undefined) set __backing_propVar9(__backing_propVar9: (IPropRefDecoratedVariable | undefined)) get __backing_propVar9(): (IPropRefDecoratedVariable | undefined) + set __options_has_propVar9(__options_has_propVar9: (boolean | undefined)) + + get __options_has_propVar9(): (boolean | undefined) set propVar10(propVar10: (Map | undefined)) get propVar10(): (Map | undefined) set __backing_propVar10(__backing_propVar10: (IPropRefDecoratedVariable> | undefined)) get __backing_propVar10(): (IPropRefDecoratedVariable> | undefined) + set __options_has_propVar10(__options_has_propVar10: (boolean | undefined)) + + get __options_has_propVar10(): (boolean | undefined) set propVar11(propVar11: ((string | number) | undefined)) get propVar11(): ((string | number) | undefined) set __backing_propVar11(__backing_propVar11: (IPropRefDecoratedVariable<(string | number)> | undefined)) get __backing_propVar11(): (IPropRefDecoratedVariable<(string | number)> | undefined) + set __options_has_propVar11(__options_has_propVar11: (boolean | undefined)) + + get __options_has_propVar11(): (boolean | undefined) set propVar12(propVar12: ((Set | Per) | undefined)) get propVar12(): ((Set | Per) | undefined) set __backing_propVar12(__backing_propVar12: (IPropRefDecoratedVariable<(Set | Per)> | undefined)) get __backing_propVar12(): (IPropRefDecoratedVariable<(Set | Per)> | undefined) + set __options_has_propVar12(__options_has_propVar12: (boolean | undefined)) + + get __options_has_propVar12(): (boolean | undefined) } `; diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/prop-ref/prop-ref-without-initialization.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/prop-ref/prop-ref-without-initialization.test.ts index e176c96e9ec5f2b52d23b06dff88706fb6e3659a..abc92ef96d19b9b3b42dc14e09d8ed9e85565893 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/prop-ref/prop-ref-without-initialization.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/prop-ref/prop-ref-without-initialization.test.ts @@ -68,18 +68,25 @@ import { PropRef as PropRef } from "@ohos.arkui.stateManagement"; @Component() export interface __Options_PropParent { propVar1?: string; @PropRef() __backing_propVar1?: string; + __options_has_propVar1?: boolean; propVar2?: (number | undefined); @PropRef() __backing_propVar2?: (number | undefined); + __options_has_propVar2?: boolean; propVar3?: boolean; @PropRef() __backing_propVar3?: boolean; + __options_has_propVar3?: boolean; propVar4?: undefined; @PropRef() __backing_propVar4?: undefined; + __options_has_propVar4?: boolean; propVar5?: null; @PropRef() __backing_propVar5?: null; + __options_has_propVar5?: boolean; propVar6?: (Array | null); @PropRef() __backing_propVar6?: (Array | null); + __options_has_propVar6?: boolean; propVar7?: (Map | undefined); @PropRef() __backing_propVar7?: (Map | undefined); + __options_has_propVar7?: boolean; } `; @@ -111,32 +118,32 @@ function main() {} } public __updateStruct(initializers: (__Options_PropParent | undefined)): void { - if (((({let gensym___67969738 = initializers; - (((gensym___67969738) == (null)) ? undefined : gensym___67969738.propVar1)})) !== (undefined))) { + if (({let gensym___222986222 = initializers; + (((gensym___222986222) == (null)) ? undefined : gensym___222986222.__options_has_propVar1)})) { this.__backing_propVar1!.update((initializers!.propVar1 as string)); } - if (((({let gensym___52350476 = initializers; - (((gensym___52350476) == (null)) ? undefined : gensym___52350476.propVar2)})) !== (undefined))) { + if (({let gensym___178023537 = initializers; + (((gensym___178023537) == (null)) ? undefined : gensym___178023537.__options_has_propVar2)})) { this.__backing_propVar2!.update((initializers!.propVar2 as (number | undefined))); } - if (((({let gensym___103864283 = initializers; - (((gensym___103864283) == (null)) ? undefined : gensym___103864283.propVar3)})) !== (undefined))) { + if (({let gensym___221361445 = initializers; + (((gensym___221361445) == (null)) ? undefined : gensym___221361445.__options_has_propVar3)})) { this.__backing_propVar3!.update((initializers!.propVar3 as boolean)); } - if (((({let gensym___175155715 = initializers; - (((gensym___175155715) == (null)) ? undefined : gensym___175155715.propVar4)})) !== (undefined))) { + if (({let gensym___22732558 = initializers; + (((gensym___22732558) == (null)) ? undefined : gensym___22732558.__options_has_propVar4)})) { this.__backing_propVar4!.update((initializers!.propVar4 as undefined)); } - if (((({let gensym___134530703 = initializers; - (((gensym___134530703) == (null)) ? undefined : gensym___134530703.propVar5)})) !== (undefined))) { + if (({let gensym___143875977 = initializers; + (((gensym___143875977) == (null)) ? undefined : gensym___143875977.__options_has_propVar5)})) { this.__backing_propVar5!.update((initializers!.propVar5 as null)); } - if (((({let gensym___211600890 = initializers; - (((gensym___211600890) == (null)) ? undefined : gensym___211600890.propVar6)})) !== (undefined))) { + if (({let gensym___21159249 = initializers; + (((gensym___21159249) == (null)) ? undefined : gensym___21159249.__options_has_propVar6)})) { this.__backing_propVar6!.update((initializers!.propVar6 as (Array | null))); } - if (((({let gensym___124229427 = initializers; - (((gensym___124229427) == (null)) ? undefined : gensym___124229427.propVar7)})) !== (undefined))) { + if (({let gensym___198355044 = initializers; + (((gensym___198355044) == (null)) ? undefined : gensym___198355044.__options_has_propVar7)})) { this.__backing_propVar7!.update((initializers!.propVar7 as (Map | undefined))); } } @@ -224,42 +231,63 @@ function main() {} set __backing_propVar1(__backing_propVar1: (IPropRefDecoratedVariable | undefined)) get __backing_propVar1(): (IPropRefDecoratedVariable | undefined) + set __options_has_propVar1(__options_has_propVar1: (boolean | undefined)) + + get __options_has_propVar1(): (boolean | undefined) set propVar2(propVar2: ((number | undefined) | undefined)) get propVar2(): ((number | undefined) | undefined) set __backing_propVar2(__backing_propVar2: (IPropRefDecoratedVariable<(number | undefined)> | undefined)) get __backing_propVar2(): (IPropRefDecoratedVariable<(number | undefined)> | undefined) + set __options_has_propVar2(__options_has_propVar2: (boolean | undefined)) + + get __options_has_propVar2(): (boolean | undefined) set propVar3(propVar3: (boolean | undefined)) get propVar3(): (boolean | undefined) set __backing_propVar3(__backing_propVar3: (IPropRefDecoratedVariable | undefined)) get __backing_propVar3(): (IPropRefDecoratedVariable | undefined) + set __options_has_propVar3(__options_has_propVar3: (boolean | undefined)) + + get __options_has_propVar3(): (boolean | undefined) set propVar4(propVar4: (undefined | undefined)) get propVar4(): (undefined | undefined) set __backing_propVar4(__backing_propVar4: (IPropRefDecoratedVariable | undefined)) get __backing_propVar4(): (IPropRefDecoratedVariable | undefined) + set __options_has_propVar4(__options_has_propVar4: (boolean | undefined)) + + get __options_has_propVar4(): (boolean | undefined) set propVar5(propVar5: (null | undefined)) get propVar5(): (null | undefined) set __backing_propVar5(__backing_propVar5: (IPropRefDecoratedVariable | undefined)) get __backing_propVar5(): (IPropRefDecoratedVariable | undefined) + set __options_has_propVar5(__options_has_propVar5: (boolean | undefined)) + + get __options_has_propVar5(): (boolean | undefined) set propVar6(propVar6: ((Array | null) | undefined)) get propVar6(): ((Array | null) | undefined) set __backing_propVar6(__backing_propVar6: (IPropRefDecoratedVariable<(Array | null)> | undefined)) get __backing_propVar6(): (IPropRefDecoratedVariable<(Array | null)> | undefined) + set __options_has_propVar6(__options_has_propVar6: (boolean | undefined)) + + get __options_has_propVar6(): (boolean | undefined) set propVar7(propVar7: ((Map | undefined) | undefined)) get propVar7(): ((Map | undefined) | undefined) set __backing_propVar7(__backing_propVar7: (IPropRefDecoratedVariable<(Map | undefined)> | undefined)) get __backing_propVar7(): (IPropRefDecoratedVariable<(Map | undefined)> | undefined) + set __options_has_propVar7(__options_has_propVar7: (boolean | undefined)) + + get __options_has_propVar7(): (boolean | undefined) } `; diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/prop-ref/state-to-propref.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/prop-ref/state-to-propref.test.ts index 93799cce2050e13aa62eec27a6fd10faaa0bed59..5ad5eec559459261cfacb6d80f43343a47cfde10 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/prop-ref/state-to-propref.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/prop-ref/state-to-propref.test.ts @@ -69,8 +69,8 @@ function main() {} } public __updateStruct(initializers: (__Options_CountDownComponent | undefined)): void { - if (((({let gensym___188547633 = initializers; - (((gensym___188547633) == (null)) ? undefined : gensym___188547633.count)})) !== (undefined))) { + if (({let gensym___142908272 = initializers; + (((gensym___142908272) == (null)) ? undefined : gensym___142908272.__options_has_count)})) { this.__backing_count!.update((initializers!.count as number)); } } @@ -158,7 +158,9 @@ function main() {} return new CountDownComponent(); }), { count: this.countDownStartValue, + __options_has_count: true, costOfOneAttempt: 2, + __options_has_costOfOneAttempt: true, }, undefined, undefined); })); } @@ -174,9 +176,15 @@ function main() {} set __backing_count(__backing_count: (IPropRefDecoratedVariable | undefined)) get __backing_count(): (IPropRefDecoratedVariable | undefined) + set __options_has_count(__options_has_count: (boolean | undefined)) + + get __options_has_count(): (boolean | undefined) set costOfOneAttempt(costOfOneAttempt: (number | undefined)) get costOfOneAttempt(): (number | undefined) + set __options_has_costOfOneAttempt(__options_has_costOfOneAttempt: (boolean | undefined)) + + get __options_has_costOfOneAttempt(): (boolean | undefined) } @@ -187,6 +195,9 @@ function main() {} set __backing_countDownStartValue(__backing_countDownStartValue: (IStateDecoratedVariable | undefined)) get __backing_countDownStartValue(): (IStateDecoratedVariable | undefined) + set __options_has_countDownStartValue(__options_has_countDownStartValue: (boolean | undefined)) + + get __options_has_countDownStartValue(): (boolean | undefined) } `; diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/prop/prop-basic-type.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/prop/prop-basic-type.test.ts deleted file mode 100644 index 9b58c22be8260da0b7ccc323b62f7aabeb65aee7..0000000000000000000000000000000000000000 --- a/arkui-plugins/test/ut/ui-plugins/decorators/prop/prop-basic-type.test.ts +++ /dev/null @@ -1,199 +0,0 @@ -/* - * 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 * as path from 'path'; -import { PluginTester } from '../../../../utils/plugin-tester'; -import { mockBuildConfig } from '../../../../utils/artkts-config'; -import { getRootPath, MOCK_ENTRY_DIR_PATH } from '../../../../utils/path-config'; -import { parseDumpSrc } from '../../../../utils/parse-string'; -import { structNoRecheck, recheck } from '../../../../utils/plugins'; -import { BuildConfig, PluginTestContext } from '../../../../utils/shared-types'; -import { uiTransform } from '../../../../../ui-plugins'; -import { Plugins } from '../../../../../common/plugin-context'; - -const BUILDER_LAMBDA_DIR_PATH: string = 'decorators/prop'; - -const buildConfig: BuildConfig = mockBuildConfig(); -buildConfig.compileFiles = [ - path.resolve(getRootPath(), MOCK_ENTRY_DIR_PATH, BUILDER_LAMBDA_DIR_PATH, 'prop-basic-type.ets'), -]; - -const pluginTester = new PluginTester('test basic type @Prop decorated variables transformation', buildConfig); - -const parsedTransform: Plugins = { - name: 'prop-basic-type', - parsed: uiTransform().parsed -}; - -const expectedScript: string = ` - -import { memo as memo } from "arkui.stateManagement.runtime"; - -import { STATE_MGMT_FACTORY as STATE_MGMT_FACTORY } from "arkui.stateManagement.decorator"; - -import { IPropDecoratedVariable as IPropDecoratedVariable } from "arkui.stateManagement.decorator"; - -import { CustomComponent as CustomComponent } from "arkui.component.customComponent"; - -import { Component as Component } from "@ohos.arkui.component"; - -import { Prop as Prop } from "@ohos.arkui.stateManagement"; - -function main() {} - - - -@Component() final struct PropParent extends CustomComponent { - public __initializeStruct(initializers: (__Options_PropParent | undefined), @memo() content: ((()=> void) | undefined)): void { - this.__backing_propVar1 = STATE_MGMT_FACTORY.makeProp(this, "propVar1", ((({let gensym___95172135 = initializers; - (((gensym___95172135) == (null)) ? undefined : gensym___95172135.propVar1)})) ?? ("propVar1"))); - this.__backing_propVar2 = STATE_MGMT_FACTORY.makeProp(this, "propVar2", ((({let gensym___222490386 = initializers; - (((gensym___222490386) == (null)) ? undefined : gensym___222490386.propVar2)})) ?? (50))); - this.__backing_propVar3 = STATE_MGMT_FACTORY.makeProp(this, "propVar3", ((({let gensym___201781257 = initializers; - (((gensym___201781257) == (null)) ? undefined : gensym___201781257.propVar3)})) ?? (true))); - this.__backing_propVar4 = STATE_MGMT_FACTORY.makeProp(this, "propVar4", ((({let gensym___22028950 = initializers; - (((gensym___22028950) == (null)) ? undefined : gensym___22028950.propVar4)})) ?? (undefined))); - this.__backing_propVar5 = STATE_MGMT_FACTORY.makeProp(this, "propVar5", ((({let gensym___54872258 = initializers; - (((gensym___54872258) == (null)) ? undefined : gensym___54872258.propVar5)})) ?? (null))); - } - - public __updateStruct(initializers: (__Options_PropParent | undefined)): void { - if (((({let gensym___67969738 = initializers; - (((gensym___67969738) == (null)) ? undefined : gensym___67969738.propVar1)})) !== (undefined))) { - this.__backing_propVar1!.update((initializers!.propVar1 as string)); - } - if (((({let gensym___52350476 = initializers; - (((gensym___52350476) == (null)) ? undefined : gensym___52350476.propVar2)})) !== (undefined))) { - this.__backing_propVar2!.update((initializers!.propVar2 as number)); - } - if (((({let gensym___103864283 = initializers; - (((gensym___103864283) == (null)) ? undefined : gensym___103864283.propVar3)})) !== (undefined))) { - this.__backing_propVar3!.update((initializers!.propVar3 as boolean)); - } - if (((({let gensym___175155715 = initializers; - (((gensym___175155715) == (null)) ? undefined : gensym___175155715.propVar4)})) !== (undefined))) { - this.__backing_propVar4!.update((initializers!.propVar4 as undefined)); - } - if (((({let gensym___134530703 = initializers; - (((gensym___134530703) == (null)) ? undefined : gensym___134530703.propVar5)})) !== (undefined))) { - this.__backing_propVar5!.update((initializers!.propVar5 as null)); - } - } - - private __backing_propVar1?: IPropDecoratedVariable; - - public get propVar1(): string { - return this.__backing_propVar1!.get(); - } - - public set propVar1(value: string) { - this.__backing_propVar1!.set(value); - } - - private __backing_propVar2?: IPropDecoratedVariable; - - public get propVar2(): number { - return this.__backing_propVar2!.get(); - } - - public set propVar2(value: number) { - this.__backing_propVar2!.set(value); - } - - private __backing_propVar3?: IPropDecoratedVariable; - - public get propVar3(): boolean { - return this.__backing_propVar3!.get(); - } - - public set propVar3(value: boolean) { - this.__backing_propVar3!.set(value); - } - - private __backing_propVar4?: IPropDecoratedVariable; - - public get propVar4(): undefined { - return this.__backing_propVar4!.get(); - } - - public set propVar4(value: undefined) { - this.__backing_propVar4!.set(value); - } - - private __backing_propVar5?: IPropDecoratedVariable; - - public get propVar5(): null { - return this.__backing_propVar5!.get(); - } - - public set propVar5(value: null) { - this.__backing_propVar5!.set(value); - } - - @memo() public build() {} - - public constructor() {} - -} - -@Component() export interface __Options_PropParent { - set propVar1(propVar1: (string | undefined)) - - get propVar1(): (string | undefined) - set __backing_propVar1(__backing_propVar1: (IPropDecoratedVariable | undefined)) - - get __backing_propVar1(): (IPropDecoratedVariable | undefined) - set propVar2(propVar2: (number | undefined)) - - get propVar2(): (number | undefined) - set __backing_propVar2(__backing_propVar2: (IPropDecoratedVariable | undefined)) - - get __backing_propVar2(): (IPropDecoratedVariable | undefined) - set propVar3(propVar3: (boolean | undefined)) - - get propVar3(): (boolean | undefined) - set __backing_propVar3(__backing_propVar3: (IPropDecoratedVariable | undefined)) - - get __backing_propVar3(): (IPropDecoratedVariable | undefined) - set propVar4(propVar4: (undefined | undefined)) - - get propVar4(): (undefined | undefined) - set __backing_propVar4(__backing_propVar4: (IPropDecoratedVariable | undefined)) - - get __backing_propVar4(): (IPropDecoratedVariable | undefined) - set propVar5(propVar5: (null | undefined)) - - get propVar5(): (null | undefined) - set __backing_propVar5(__backing_propVar5: (IPropDecoratedVariable | undefined)) - - get __backing_propVar5(): (IPropDecoratedVariable | undefined) - -} -`; - -function testParsedAndCheckedTransformer(this: PluginTestContext): void { - expect(parseDumpSrc(this.scriptSnapshot ?? '')).toBe(parseDumpSrc(expectedScript)); -} - -pluginTester.run( - 'test basic type @Prop decorated variables transformation', - [parsedTransform, structNoRecheck, recheck], - { - 'checked:struct-no-recheck': [testParsedAndCheckedTransformer], - }, - { - stopAfter: 'checked', - } -); diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/prop/prop-complex-type.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/prop/prop-complex-type.test.ts deleted file mode 100644 index c619e10ce290e731a8a5a2db4a4ec90274217eac..0000000000000000000000000000000000000000 --- a/arkui-plugins/test/ut/ui-plugins/decorators/prop/prop-complex-type.test.ts +++ /dev/null @@ -1,428 +0,0 @@ -/* - * 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 * as path from 'path'; -import { PluginTester } from '../../../../utils/plugin-tester'; -import { mockBuildConfig } from '../../../../utils/artkts-config'; -import { getRootPath, MOCK_ENTRY_DIR_PATH } from '../../../../utils/path-config'; -import { parseDumpSrc } from '../../../../utils/parse-string'; -import { structNoRecheck, recheck } from '../../../../utils/plugins'; -import { BuildConfig, PluginTestContext } from '../../../../utils/shared-types'; -import { uiTransform } from '../../../../../ui-plugins'; -import { Plugins } from '../../../../../common/plugin-context'; - -const BUILDER_LAMBDA_DIR_PATH: string = 'decorators/prop'; - -const buildConfig: BuildConfig = mockBuildConfig(); -buildConfig.compileFiles = [ - path.resolve(getRootPath(), MOCK_ENTRY_DIR_PATH, BUILDER_LAMBDA_DIR_PATH, 'prop-complex-type.ets'), -]; - -const pluginTester = new PluginTester('test complex type @Prop decorated variables transformation', buildConfig); - -const parsedTransform: Plugins = { - name: 'prop-complex-type', - parsed: uiTransform().parsed -}; - -const expectedScript: string = ` -import { memo as memo } from "arkui.stateManagement.runtime"; - -import { STATE_MGMT_FACTORY as STATE_MGMT_FACTORY } from "arkui.stateManagement.decorator"; - -import { IPropDecoratedVariable as IPropDecoratedVariable } from "arkui.stateManagement.decorator"; - - -import { CustomComponent as CustomComponent } from "arkui.component.customComponent"; - -import { Component as Component } from "@ohos.arkui.component"; - -import { Prop as Prop } from "@ohos.arkui.stateManagement"; - -function main() {} - -class Per { - public num: number; - - public constructor(num: number) { - this.num = num; - } - -} - -final class PropType extends BaseEnum { - private readonly #ordinal: int; - - private static () {} - - public constructor(ordinal: int, value: int) { - super(value); - this.#ordinal = ordinal; - } - - public static readonly TYPE1: PropType = new PropType(0, 0); - - public static readonly TYPE2: PropType = new PropType(1, 1); - - public static readonly TYPE3: PropType = new PropType(2, 3); - - private static readonly #NamesArray: String[] = ["TYPE1", "TYPE2", "TYPE3"]; - - private static readonly #ValuesArray: int[] = [0, 1, 3]; - - private static readonly #StringValuesArray: String[] = ["0", "1", "3"]; - - private static readonly #ItemsArray: PropType[] = [PropType.TYPE1, PropType.TYPE2, PropType.TYPE3]; - - public getName(): String { - return PropType.#NamesArray[this.#ordinal]; - } - - public static getValueOf(name: String): PropType { - for (let i = 0;((i) < (PropType.#NamesArray.length));(++i)) { - if (((name) == (PropType.#NamesArray[i]))) { - return PropType.#ItemsArray[i]; - } - } - throw new Error((("No enum constant PropType.") + (name))); - } - - public static fromValue(value: int): PropType { - for (let i = 0;((i) < (PropType.#ValuesArray.length));(++i)) { - if (((value) == (PropType.#ValuesArray[i]))) { - return PropType.#ItemsArray[i]; - } - } - throw new Error((("No enum PropType with value ") + (value))); - } - - public valueOf(): int { - return PropType.#ValuesArray[this.#ordinal]; - } - - public toString(): String { - return PropType.#StringValuesArray[this.#ordinal]; - } - - public static values(): PropType[] { - return PropType.#ItemsArray; - } - - public getOrdinal(): int { - return this.#ordinal; - } - - public static $_get(e: PropType): String { - return e.getName(); - } - -} - -@Component() final struct Parent extends CustomComponent { - public __initializeStruct(initializers: (__Options_Parent | undefined), @memo() content: ((()=> void) | undefined)): void { - this.__backing_propVar1 = STATE_MGMT_FACTORY.makeProp(this, "propVar1", ((({let gensym___95172135 = initializers; - (((gensym___95172135) == (null)) ? undefined : gensym___95172135.propVar1)})) ?? (new Per(6)))); - this.__backing_propVar2 = STATE_MGMT_FACTORY.makeProp>(this, "propVar2", ((({let gensym___222490386 = initializers; - (((gensym___222490386) == (null)) ? undefined : gensym___222490386.propVar2)})) ?? (new Array(3, 6, 8)))); - this.__backing_propVar3 = STATE_MGMT_FACTORY.makeProp(this, "propVar3", ((({let gensym___201781257 = initializers; - (((gensym___201781257) == (null)) ? undefined : gensym___201781257.propVar3)})) ?? (PropType.TYPE3))); - this.__backing_propVar4 = STATE_MGMT_FACTORY.makeProp>(this, "propVar4", ((({let gensym___22028950 = initializers; - (((gensym___22028950) == (null)) ? undefined : gensym___22028950.propVar4)})) ?? (new Set(new Array("aa", "bb"))))); - this.__backing_propVar5 = STATE_MGMT_FACTORY.makeProp>(this, "propVar5", ((({let gensym___54872258 = initializers; - (((gensym___54872258) == (null)) ? undefined : gensym___54872258.propVar5)})) ?? ([true, false]))); - this.__backing_propVar6 = STATE_MGMT_FACTORY.makeProp>(this, "propVar6", ((({let gensym___128760941 = initializers; - (((gensym___128760941) == (null)) ? undefined : gensym___128760941.propVar6)})) ?? (new Array(new Per(7), new Per(11))))); - this.__backing_propVar7 = STATE_MGMT_FACTORY.makeProp>(this, "propVar7", ((({let gensym___30534085 = initializers; - (((gensym___30534085) == (null)) ? undefined : gensym___30534085.propVar7)})) ?? ([new Per(7), new Per(11)]))); - this.__backing_propVar8 = STATE_MGMT_FACTORY.makeProp<((sr: string)=> void)>(this, "propVar8", ((({let gensym___12471776 = initializers; - (((gensym___12471776) == (null)) ? undefined : gensym___12471776.propVar8)})) ?? (((sr: string) => {})))); - this.__backing_propVar9 = STATE_MGMT_FACTORY.makeProp(this, "propVar9", ((({let gensym___123472108 = initializers; - (((gensym___123472108) == (null)) ? undefined : gensym___123472108.propVar9)})) ?? (new Date("2025-4-23")))); - this.__backing_propVar10 = STATE_MGMT_FACTORY.makeProp>(this, "propVar10", ((({let gensym___147847012 = initializers; - (((gensym___147847012) == (null)) ? undefined : gensym___147847012.propVar10)})) ?? (new Map([[0, new Per(7)], [1, new Per(10)]])))); - this.__backing_propVar11 = STATE_MGMT_FACTORY.makeProp<(string | number)>(this, "propVar11", ((({let gensym___117026760 = initializers; - (((gensym___117026760) == (null)) ? undefined : gensym___117026760.propVar11)})) ?? (0.0))); - this.__backing_propVar12 = STATE_MGMT_FACTORY.makeProp<(Set | Per)>(this, "propVar12", ((({let gensym___220245132 = initializers; - (((gensym___220245132) == (null)) ? undefined : gensym___220245132.propVar12)})) ?? (new Per(6)))); - } - - public __updateStruct(initializers: (__Options_Parent | undefined)): void { - if (((({let gensym___67969738 = initializers; - (((gensym___67969738) == (null)) ? undefined : gensym___67969738.propVar1)})) !== (undefined))) { - this.__backing_propVar1!.update((initializers!.propVar1 as Per)); - } - if (((({let gensym___52350476 = initializers; - (((gensym___52350476) == (null)) ? undefined : gensym___52350476.propVar2)})) !== (undefined))) { - this.__backing_propVar2!.update((initializers!.propVar2 as Array)); - } - if (((({let gensym___103864283 = initializers; - (((gensym___103864283) == (null)) ? undefined : gensym___103864283.propVar3)})) !== (undefined))) { - this.__backing_propVar3!.update((initializers!.propVar3 as PropType)); - } - if (((({let gensym___175155715 = initializers; - (((gensym___175155715) == (null)) ? undefined : gensym___175155715.propVar4)})) !== (undefined))) { - this.__backing_propVar4!.update((initializers!.propVar4 as Set)); - } - if (((({let gensym___134530703 = initializers; - (((gensym___134530703) == (null)) ? undefined : gensym___134530703.propVar5)})) !== (undefined))) { - this.__backing_propVar5!.update((initializers!.propVar5 as Array)); - } - if (((({let gensym___211600890 = initializers; - (((gensym___211600890) == (null)) ? undefined : gensym___211600890.propVar6)})) !== (undefined))) { - this.__backing_propVar6!.update((initializers!.propVar6 as Array)); - } - if (((({let gensym___124229427 = initializers; - (((gensym___124229427) == (null)) ? undefined : gensym___124229427.propVar7)})) !== (undefined))) { - this.__backing_propVar7!.update((initializers!.propVar7 as Array)); - } - if (((({let gensym___248056380 = initializers; - (((gensym___248056380) == (null)) ? undefined : gensym___248056380.propVar8)})) !== (undefined))) { - this.__backing_propVar8!.update((initializers!.propVar8 as ((sr: string)=> void))); - } - if (((({let gensym___55399278 = initializers; - (((gensym___55399278) == (null)) ? undefined : gensym___55399278.propVar9)})) !== (undefined))) { - this.__backing_propVar9!.update((initializers!.propVar9 as Date)); - } - if (((({let gensym___125042885 = initializers; - (((gensym___125042885) == (null)) ? undefined : gensym___125042885.propVar10)})) !== (undefined))) { - this.__backing_propVar10!.update((initializers!.propVar10 as Map)); - } - if (((({let gensym___2015283 = initializers; - (((gensym___2015283) == (null)) ? undefined : gensym___2015283.propVar11)})) !== (undefined))) { - this.__backing_propVar11!.update((initializers!.propVar11 as (string | number))); - } - if (((({let gensym___39009414 = initializers; - (((gensym___39009414) == (null)) ? undefined : gensym___39009414.propVar12)})) !== (undefined))) { - this.__backing_propVar12!.update((initializers!.propVar12 as (Set | Per))); - } - } - - private __backing_propVar1?: IPropDecoratedVariable; - - public get propVar1(): Per { - return this.__backing_propVar1!.get(); - } - - public set propVar1(value: Per) { - this.__backing_propVar1!.set(value); - } - - private __backing_propVar2?: IPropDecoratedVariable>; - - public get propVar2(): Array { - return this.__backing_propVar2!.get(); - } - - public set propVar2(value: Array) { - this.__backing_propVar2!.set(value); - } - - private __backing_propVar3?: IPropDecoratedVariable; - - public get propVar3(): PropType { - return this.__backing_propVar3!.get(); - } - - public set propVar3(value: PropType) { - this.__backing_propVar3!.set(value); - } - - private __backing_propVar4?: IPropDecoratedVariable>; - - public get propVar4(): Set { - return this.__backing_propVar4!.get(); - } - - public set propVar4(value: Set) { - this.__backing_propVar4!.set(value); - } - - private __backing_propVar5?: IPropDecoratedVariable>; - - public get propVar5(): Array { - return this.__backing_propVar5!.get(); - } - - public set propVar5(value: Array) { - this.__backing_propVar5!.set(value); - } - - private __backing_propVar6?: IPropDecoratedVariable>; - - public get propVar6(): Array { - return this.__backing_propVar6!.get(); - } - - public set propVar6(value: Array) { - this.__backing_propVar6!.set(value); - } - - private __backing_propVar7?: IPropDecoratedVariable>; - - public get propVar7(): Array { - return this.__backing_propVar7!.get(); - } - - public set propVar7(value: Array) { - this.__backing_propVar7!.set(value); - } - - private __backing_propVar8?: IPropDecoratedVariable<((sr: string)=> void)>; - - public get propVar8(): ((sr: string)=> void) { - return this.__backing_propVar8!.get(); - } - - public set propVar8(value: ((sr: string)=> void)) { - this.__backing_propVar8!.set(value); - } - - private __backing_propVar9?: IPropDecoratedVariable; - - public get propVar9(): Date { - return this.__backing_propVar9!.get(); - } - - public set propVar9(value: Date) { - this.__backing_propVar9!.set(value); - } - - private __backing_propVar10?: IPropDecoratedVariable>; - - public get propVar10(): Map { - return this.__backing_propVar10!.get(); - } - - public set propVar10(value: Map) { - this.__backing_propVar10!.set(value); - } - - private __backing_propVar11?: IPropDecoratedVariable<(string | number)>; - - public get propVar11(): (string | number) { - return this.__backing_propVar11!.get(); - } - - public set propVar11(value: (string | number)) { - this.__backing_propVar11!.set(value); - } - - private __backing_propVar12?: IPropDecoratedVariable<(Set | Per)>; - - public get propVar12(): (Set | Per) { - return this.__backing_propVar12!.get(); - } - - public set propVar12(value: (Set | Per)) { - this.__backing_propVar12!.set(value); - } - - @memo() public build() {} - - public constructor() {} - -} - -@Component() export interface __Options_Parent { - set propVar1(propVar1: (Per | undefined)) - - get propVar1(): (Per | undefined) - set __backing_propVar1(__backing_propVar1: (IPropDecoratedVariable | undefined)) - - get __backing_propVar1(): (IPropDecoratedVariable | undefined) - set propVar2(propVar2: (Array | undefined)) - - get propVar2(): (Array | undefined) - set __backing_propVar2(__backing_propVar2: (IPropDecoratedVariable> | undefined)) - - get __backing_propVar2(): (IPropDecoratedVariable> | undefined) - set propVar3(propVar3: (PropType | undefined)) - - get propVar3(): (PropType | undefined) - set __backing_propVar3(__backing_propVar3: (IPropDecoratedVariable | undefined)) - - get __backing_propVar3(): (IPropDecoratedVariable | undefined) - set propVar4(propVar4: (Set | undefined)) - - get propVar4(): (Set | undefined) - set __backing_propVar4(__backing_propVar4: (IPropDecoratedVariable> | undefined)) - - get __backing_propVar4(): (IPropDecoratedVariable> | undefined) - set propVar5(propVar5: (Array | undefined)) - - get propVar5(): (Array | undefined) - set __backing_propVar5(__backing_propVar5: (IPropDecoratedVariable> | undefined)) - - get __backing_propVar5(): (IPropDecoratedVariable> | undefined) - set propVar6(propVar6: (Array | undefined)) - - get propVar6(): (Array | undefined) - set __backing_propVar6(__backing_propVar6: (IPropDecoratedVariable> | undefined)) - - get __backing_propVar6(): (IPropDecoratedVariable> | undefined) - set propVar7(propVar7: (Array | undefined)) - - get propVar7(): (Array | undefined) - set __backing_propVar7(__backing_propVar7: (IPropDecoratedVariable> | undefined)) - - get __backing_propVar7(): (IPropDecoratedVariable> | undefined) - set propVar8(propVar8: (((sr: string)=> void) | undefined)) - - get propVar8(): (((sr: string)=> void) | undefined) - set __backing_propVar8(__backing_propVar8: (IPropDecoratedVariable<((sr: string)=> void)> | undefined)) - - get __backing_propVar8(): (IPropDecoratedVariable<((sr: string)=> void)> | undefined) - set propVar9(propVar9: (Date | undefined)) - - get propVar9(): (Date | undefined) - set __backing_propVar9(__backing_propVar9: (IPropDecoratedVariable | undefined)) - - get __backing_propVar9(): (IPropDecoratedVariable | undefined) - set propVar10(propVar10: (Map | undefined)) - - get propVar10(): (Map | undefined) - set __backing_propVar10(__backing_propVar10: (IPropDecoratedVariable> | undefined)) - - get __backing_propVar10(): (IPropDecoratedVariable> | undefined) - set propVar11(propVar11: ((string | number) | undefined)) - - get propVar11(): ((string | number) | undefined) - set __backing_propVar11(__backing_propVar11: (IPropDecoratedVariable<(string | number)> | undefined)) - - get __backing_propVar11(): (IPropDecoratedVariable<(string | number)> | undefined) - set propVar12(propVar12: ((Set | Per) | undefined)) - - get propVar12(): ((Set | Per) | undefined) - set __backing_propVar12(__backing_propVar12: (IPropDecoratedVariable<(Set | Per)> | undefined)) - - get __backing_propVar12(): (IPropDecoratedVariable<(Set | Per)> | undefined) - -} -`; - -function testParsedAndCheckedTransformer(this: PluginTestContext): void { - expect(parseDumpSrc(this.scriptSnapshot ?? '')).toBe(parseDumpSrc(expectedScript)); -} - -pluginTester.run( - 'test complex type @Prop decorated variables transformation', - [parsedTransform, structNoRecheck, recheck], - { - 'checked:struct-no-recheck': [testParsedAndCheckedTransformer], - }, - { - stopAfter: 'checked', - } -); diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/prop/state-to-prop.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/prop/state-to-prop.test.ts deleted file mode 100644 index 3166366c13b4deff4ce9e99030039c5e5fca1d86..0000000000000000000000000000000000000000 --- a/arkui-plugins/test/ut/ui-plugins/decorators/prop/state-to-prop.test.ts +++ /dev/null @@ -1,207 +0,0 @@ -/* - * 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 * as path from 'path'; -import { PluginTester } from '../../../../utils/plugin-tester'; -import { mockBuildConfig } from '../../../../utils/artkts-config'; -import { getRootPath, MOCK_ENTRY_DIR_PATH } from '../../../../utils/path-config'; -import { parseDumpSrc } from '../../../../utils/parse-string'; -import { uiNoRecheck, recheck } from '../../../../utils/plugins'; -import { BuildConfig, PluginTestContext } from '../../../../utils/shared-types'; -import { uiTransform } from '../../../../../ui-plugins'; -import { Plugins } from '../../../../../common/plugin-context'; - -const BUILDER_LAMBDA_DIR_PATH: string = 'decorators/prop'; - -const buildConfig: BuildConfig = mockBuildConfig(); -buildConfig.compileFiles = [ - path.resolve(getRootPath(), MOCK_ENTRY_DIR_PATH, BUILDER_LAMBDA_DIR_PATH, 'state-to-prop.ets'), -]; - -const pluginTester = new PluginTester('test @Prop decorated variables passing', buildConfig); - -const parsedTransform: Plugins = { - name: 'state-to-prop', - parsed: uiTransform().parsed -}; - -const expectedScript: string = ` -import { IStateDecoratedVariable as IStateDecoratedVariable } from "arkui.stateManagement.decorator"; - -import { STATE_MGMT_FACTORY as STATE_MGMT_FACTORY } from "arkui.stateManagement.decorator"; - -import { IPropDecoratedVariable as IPropDecoratedVariable } from "arkui.stateManagement.decorator"; - -import { ButtonAttribute as ButtonAttribute } from "arkui.component.button"; - -import { ConditionScope as ConditionScope } from "arkui.component.builder"; - -import { ConditionBranch as ConditionBranch } from "arkui.component.builder"; - -import { memo as memo } from "arkui.stateManagement.runtime"; - -import { CustomComponent as CustomComponent } from "arkui.component.customComponent"; - -import { Component as Component, Text as Text, Button as Button, Column as Column, ClickEvent as ClickEvent } from "@ohos.arkui.component"; - -import { Prop as Prop, State as State } from "@ohos.arkui.stateManagement"; - -function main() {} - -@Component() final struct CountDownComponent extends CustomComponent { - public __initializeStruct(initializers: (__Options_CountDownComponent | undefined), @memo() content: ((()=> void) | undefined)): void { - this.__backing_count = STATE_MGMT_FACTORY.makeProp(this, "count", ((({let gensym___58710805 = initializers; - (((gensym___58710805) == (null)) ? undefined : gensym___58710805.count)})) ?? (0))); - this.__backing_costOfOneAttempt = ((({let gensym___88948111 = initializers; - (((gensym___88948111) == (null)) ? undefined : gensym___88948111.costOfOneAttempt)})) ?? (1)); - } - - public __updateStruct(initializers: (__Options_CountDownComponent | undefined)): void { - if (((({let gensym___188547633 = initializers; - (((gensym___188547633) == (null)) ? undefined : gensym___188547633.count)})) !== (undefined))) { - this.__backing_count!.update((initializers!.count as number)); - } - } - - private __backing_count?: IPropDecoratedVariable; - - public get count(): number { - return this.__backing_count!.get(); - } - - public set count(value: number) { - this.__backing_count!.set(value); - } - - private __backing_costOfOneAttempt?: number; - - public get costOfOneAttempt(): number { - return (this.__backing_costOfOneAttempt as number); - } - - public set costOfOneAttempt(value: number) { - this.__backing_costOfOneAttempt = value; - } - - @memo() public build() { - Column(undefined, undefined, @memo() (() => { - ConditionScope(@memo() (() => { - if (((this.count) > (0))) { - ConditionBranch(@memo() (() => { - Text(undefined, (((("You have") + (this.count))) + ("Nuggets left")), undefined, undefined); - })); - } else { - ConditionBranch(@memo() (() => { - Text(undefined, "Game over!", undefined, undefined); - })); - } - })); - Button(@memo() ((instance: ButtonAttribute): void => { - instance.onClick(((e: ClickEvent) => { - this.count -= this.costOfOneAttempt; - })); - return; - }), "Try again", undefined, undefined); - })); - } - - public constructor() {} - -} - -@Component() final struct ParentComponent extends CustomComponent { - public __initializeStruct(initializers: (__Options_ParentComponent | undefined), @memo() content: ((()=> void) | undefined)): void { - this.__backing_countDownStartValue = STATE_MGMT_FACTORY.makeState(this, "countDownStartValue", ((({let gensym___249912438 = initializers; - (((gensym___249912438) == (null)) ? undefined : gensym___249912438.countDownStartValue)})) ?? (10))); - } - - public __updateStruct(initializers: (__Options_ParentComponent | undefined)): void {} - - private __backing_countDownStartValue?: IStateDecoratedVariable; - - public get countDownStartValue(): number { - return this.__backing_countDownStartValue!.get(); - } - - public set countDownStartValue(value: number) { - this.__backing_countDownStartValue!.set(value); - } - - @memo() public build() { - Column(undefined, undefined, @memo() (() => { - Text(undefined, (((("Grant") + (this.countDownStartValue))) + ("nuggets to play.")), undefined, undefined); - Button(@memo() ((instance: ButtonAttribute): void => { - instance.onClick(((e: ClickEvent) => { - this.countDownStartValue += 1; - })); - return; - }), "+1 - Nuggets in New Game", undefined, undefined); - Button(@memo() ((instance: ButtonAttribute): void => { - instance.onClick(((e: ClickEvent) => { - this.countDownStartValue -= 1; - })); - return; - }), "-1 - Nuggets in New Game", undefined, undefined); - CountDownComponent._instantiateImpl(undefined, (() => { - return new CountDownComponent(); - }), { - count: this.countDownStartValue, - costOfOneAttempt: 2, - }, undefined, undefined); - })); - } - - public constructor() {} - -} - -@Component() export interface __Options_CountDownComponent { - set count(count: (number | undefined)) - - get count(): (number | undefined) - set __backing_count(__backing_count: (IPropDecoratedVariable | undefined)) - - get __backing_count(): (IPropDecoratedVariable | undefined) - set costOfOneAttempt(costOfOneAttempt: (number | undefined)) - - get costOfOneAttempt(): (number | undefined) - -} - -@Component() export interface __Options_ParentComponent { - set countDownStartValue(countDownStartValue: (number | undefined)) - - get countDownStartValue(): (number | undefined) - set __backing_countDownStartValue(__backing_countDownStartValue: (IStateDecoratedVariable | undefined)) - - get __backing_countDownStartValue(): (IStateDecoratedVariable | undefined) - -} -`; - -function testParsedAndCheckedTransformer(this: PluginTestContext): void { - expect(parseDumpSrc(this.scriptSnapshot ?? '')).toBe(parseDumpSrc(expectedScript)); -} - -pluginTester.run( - 'test @Prop decorated variables passing', - [parsedTransform, uiNoRecheck, recheck], - { - 'checked:ui-no-recheck': [testParsedAndCheckedTransformer], - }, - { - stopAfter: 'checked', - } -); diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/provide-and-consume/consume-basic-type.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/provide-and-consume/consume-basic-type.test.ts index f0e7053e3a067934bba68078b6ee5d79d30da74c..738828d241d128858f65636008aba108940ae240 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/provide-and-consume/consume-basic-type.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/provide-and-consume/consume-basic-type.test.ts @@ -64,14 +64,19 @@ import { Consume as Consume } from "@ohos.arkui.stateManagement"; @Component() export interface __Options_PropParent { conVar1?: string; @Consume() __backing_conVar1?: string; + __options_has_conVar1?: boolean; conVar2?: number; @Consume() __backing_conVar2?: number; + __options_has_conVar2?: boolean; conVar3?: boolean; @Consume() __backing_conVar3?: boolean; + __options_has_conVar3?: boolean; conVar4?: undefined; @Consume() __backing_conVar4?: undefined; + __options_has_conVar4?: boolean; conVar5?: null; @Consume() __backing_conVar5?: null; + __options_has_conVar5?: boolean; } `; @@ -167,30 +172,45 @@ function main() {} set __backing_conVar1(__backing_conVar1: (IConsumeDecoratedVariable | undefined)) get __backing_conVar1(): (IConsumeDecoratedVariable | undefined) + set __options_has_conVar1(__options_has_conVar1: (boolean | undefined)) + + get __options_has_conVar1(): (boolean | undefined) set conVar2(conVar2: (number | undefined)) get conVar2(): (number | undefined) set __backing_conVar2(__backing_conVar2: (IConsumeDecoratedVariable | undefined)) get __backing_conVar2(): (IConsumeDecoratedVariable | undefined) + set __options_has_conVar2(__options_has_conVar2: (boolean | undefined)) + + get __options_has_conVar2(): (boolean | undefined) set conVar3(conVar3: (boolean | undefined)) get conVar3(): (boolean | undefined) set __backing_conVar3(__backing_conVar3: (IConsumeDecoratedVariable | undefined)) get __backing_conVar3(): (IConsumeDecoratedVariable | undefined) + set __options_has_conVar3(__options_has_conVar3: (boolean | undefined)) + + get __options_has_conVar3(): (boolean | undefined) set conVar4(conVar4: (undefined | undefined)) get conVar4(): (undefined | undefined) set __backing_conVar4(__backing_conVar4: (IConsumeDecoratedVariable | undefined)) get __backing_conVar4(): (IConsumeDecoratedVariable | undefined) + set __options_has_conVar4(__options_has_conVar4: (boolean | undefined)) + + get __options_has_conVar4(): (boolean | undefined) set conVar5(conVar5: (null | undefined)) get conVar5(): (null | undefined) set __backing_conVar5(__backing_conVar5: (IConsumeDecoratedVariable | undefined)) get __backing_conVar5(): (IConsumeDecoratedVariable | undefined) + set __options_has_conVar5(__options_has_conVar5: (boolean | undefined)) + + get __options_has_conVar5(): (boolean | undefined) } `; diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/provide-and-consume/consume-complex-type.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/provide-and-consume/consume-complex-type.test.ts index 202edb7b0ec1bebb19401f90a3f1cbbc7b03980c..64e085c6c5cfb12fbc6be8b4e1f738728f8eede9 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/provide-and-consume/consume-complex-type.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/provide-and-consume/consume-complex-type.test.ts @@ -95,30 +95,43 @@ enum PropType { @Component() export interface __Options_Parent { conVar1?: Per; @Consume() __backing_conVar1?: Per; + __options_has_conVar1?: boolean; conVar2?: Array; @Consume() __backing_conVar2?: Array; + __options_has_conVar2?: boolean; conVar3?: PropType; @Consume() __backing_conVar3?: PropType; + __options_has_conVar3?: boolean; conVar4?: Set; @Consume() __backing_conVar4?: Set; + __options_has_conVar4?: boolean; conVar5?: boolean[]; @Consume() __backing_conVar5?: boolean[]; + __options_has_conVar5?: boolean; conVar6?: Array; @Consume() __backing_conVar6?: Array; + __options_has_conVar6?: boolean; conVar7?: Per[]; @Consume() __backing_conVar7?: Per[]; + __options_has_conVar7?: boolean; conVar8?: ((sr: string)=> void); @Consume() __backing_conVar8?: ((sr: string)=> void); + __options_has_conVar8?: boolean; conVar9?: Date; @Consume() __backing_conVar9?: Date; + __options_has_conVar9?: boolean; conVar10?: Map; @Consume() __backing_conVar10?: Map; + __options_has_conVar10?: boolean; conVar11?: (string | number); @Consume() __backing_conVar11?: (string | number); + __options_has_conVar11?: boolean; conVar12?: (Set | Per); @Consume() __backing_conVar12?: (Set | Per); + __options_has_conVar12?: boolean; conVar13?: (Set | null); @Consume() __backing_conVar13?: (Set | null); + __options_has_conVar13?: boolean; } `; @@ -379,78 +392,117 @@ final class PropType extends BaseEnum { set __backing_conVar1(__backing_conVar1: (IConsumeDecoratedVariable | undefined)) get __backing_conVar1(): (IConsumeDecoratedVariable | undefined) + set __options_has_conVar1(__options_has_conVar1: (boolean | undefined)) + + get __options_has_conVar1(): (boolean | undefined) set conVar2(conVar2: (Array | undefined)) get conVar2(): (Array | undefined) set __backing_conVar2(__backing_conVar2: (IConsumeDecoratedVariable> | undefined)) get __backing_conVar2(): (IConsumeDecoratedVariable> | undefined) + set __options_has_conVar2(__options_has_conVar2: (boolean | undefined)) + + get __options_has_conVar2(): (boolean | undefined) set conVar3(conVar3: (PropType | undefined)) get conVar3(): (PropType | undefined) set __backing_conVar3(__backing_conVar3: (IConsumeDecoratedVariable | undefined)) get __backing_conVar3(): (IConsumeDecoratedVariable | undefined) + set __options_has_conVar3(__options_has_conVar3: (boolean | undefined)) + + get __options_has_conVar3(): (boolean | undefined) set conVar4(conVar4: (Set | undefined)) get conVar4(): (Set | undefined) set __backing_conVar4(__backing_conVar4: (IConsumeDecoratedVariable> | undefined)) get __backing_conVar4(): (IConsumeDecoratedVariable> | undefined) + set __options_has_conVar4(__options_has_conVar4: (boolean | undefined)) + + get __options_has_conVar4(): (boolean | undefined) set conVar5(conVar5: (Array | undefined)) get conVar5(): (Array | undefined) set __backing_conVar5(__backing_conVar5: (IConsumeDecoratedVariable> | undefined)) get __backing_conVar5(): (IConsumeDecoratedVariable> | undefined) + set __options_has_conVar5(__options_has_conVar5: (boolean | undefined)) + + get __options_has_conVar5(): (boolean | undefined) set conVar6(conVar6: (Array | undefined)) get conVar6(): (Array | undefined) set __backing_conVar6(__backing_conVar6: (IConsumeDecoratedVariable> | undefined)) get __backing_conVar6(): (IConsumeDecoratedVariable> | undefined) + set __options_has_conVar6(__options_has_conVar6: (boolean | undefined)) + + get __options_has_conVar6(): (boolean | undefined) set conVar7(conVar7: (Array | undefined)) get conVar7(): (Array | undefined) set __backing_conVar7(__backing_conVar7: (IConsumeDecoratedVariable> | undefined)) get __backing_conVar7(): (IConsumeDecoratedVariable> | undefined) + set __options_has_conVar7(__options_has_conVar7: (boolean | undefined)) + + get __options_has_conVar7(): (boolean | undefined) set conVar8(conVar8: (((sr: string)=> void) | undefined)) get conVar8(): (((sr: string)=> void) | undefined) set __backing_conVar8(__backing_conVar8: (IConsumeDecoratedVariable<((sr: string)=> void)> | undefined)) get __backing_conVar8(): (IConsumeDecoratedVariable<((sr: string)=> void)> | undefined) + set __options_has_conVar8(__options_has_conVar8: (boolean | undefined)) + + get __options_has_conVar8(): (boolean | undefined) set conVar9(conVar9: (Date | undefined)) get conVar9(): (Date | undefined) set __backing_conVar9(__backing_conVar9: (IConsumeDecoratedVariable | undefined)) get __backing_conVar9(): (IConsumeDecoratedVariable | undefined) + set __options_has_conVar9(__options_has_conVar9: (boolean | undefined)) + + get __options_has_conVar9(): (boolean | undefined) set conVar10(conVar10: (Map | undefined)) get conVar10(): (Map | undefined) set __backing_conVar10(__backing_conVar10: (IConsumeDecoratedVariable> | undefined)) get __backing_conVar10(): (IConsumeDecoratedVariable> | undefined) + set __options_has_conVar10(__options_has_conVar10: (boolean | undefined)) + + get __options_has_conVar10(): (boolean | undefined) set conVar11(conVar11: ((string | number) | undefined)) get conVar11(): ((string | number) | undefined) set __backing_conVar11(__backing_conVar11: (IConsumeDecoratedVariable<(string | number)> | undefined)) get __backing_conVar11(): (IConsumeDecoratedVariable<(string | number)> | undefined) + set __options_has_conVar11(__options_has_conVar11: (boolean | undefined)) + + get __options_has_conVar11(): (boolean | undefined) set conVar12(conVar12: ((Set | Per) | undefined)) get conVar12(): ((Set | Per) | undefined) set __backing_conVar12(__backing_conVar12: (IConsumeDecoratedVariable<(Set | Per)> | undefined)) get __backing_conVar12(): (IConsumeDecoratedVariable<(Set | Per)> | undefined) + set __options_has_conVar12(__options_has_conVar12: (boolean | undefined)) + + get __options_has_conVar12(): (boolean | undefined) set conVar13(conVar13: ((Set | null) | undefined)) get conVar13(): ((Set | null) | undefined) set __backing_conVar13(__backing_conVar13: (IConsumeDecoratedVariable<(Set | null)> | undefined)) get __backing_conVar13(): (IConsumeDecoratedVariable<(Set | null)> | undefined) + set __options_has_conVar13(__options_has_conVar13: (boolean | undefined)) + + get __options_has_conVar13(): (boolean | undefined) } `; diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/provide-and-consume/provide-annotation-usage.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/provide-and-consume/provide-annotation-usage.test.ts index 195bb2726f284136c55af59e171f7baf0e25495a..e47739f418baabac612cabd948909272231a2b94 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/provide-and-consume/provide-annotation-usage.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/provide-and-consume/provide-annotation-usage.test.ts @@ -44,7 +44,6 @@ import { IProvideDecoratedVariable as IProvideDecoratedVariable } from "arkui.st import { STATE_MGMT_FACTORY as STATE_MGMT_FACTORY } from "arkui.stateManagement.decorator"; - import { CustomComponent as CustomComponent } from "arkui.component.customComponent"; import { Component as Component } from "@ohos.arkui.component"; @@ -168,48 +167,72 @@ function main() {} set __backing_count(__backing_count: (IProvideDecoratedVariable<(string | undefined)> | undefined)) get __backing_count(): (IProvideDecoratedVariable<(string | undefined)> | undefined) + set __options_has_count(__options_has_count: (boolean | undefined)) + + get __options_has_count(): (boolean | undefined) set count1(count1: ((string | undefined) | undefined)) get count1(): ((string | undefined) | undefined) set __backing_count1(__backing_count1: (IProvideDecoratedVariable<(string | undefined)> | undefined)) get __backing_count1(): (IProvideDecoratedVariable<(string | undefined)> | undefined) + set __options_has_count1(__options_has_count1: (boolean | undefined)) + + get __options_has_count1(): (boolean | undefined) set count2(count2: ((string | undefined) | undefined)) get count2(): ((string | undefined) | undefined) set __backing_count2(__backing_count2: (IProvideDecoratedVariable<(string | undefined)> | undefined)) get __backing_count2(): (IProvideDecoratedVariable<(string | undefined)> | undefined) + set __options_has_count2(__options_has_count2: (boolean | undefined)) + + get __options_has_count2(): (boolean | undefined) set count3(count3: ((string | undefined) | undefined)) get count3(): ((string | undefined) | undefined) set __backing_count3(__backing_count3: (IProvideDecoratedVariable<(string | undefined)> | undefined)) get __backing_count3(): (IProvideDecoratedVariable<(string | undefined)> | undefined) + set __options_has_count3(__options_has_count3: (boolean | undefined)) + + get __options_has_count3(): (boolean | undefined) set count4(count4: ((string | undefined) | undefined)) get count4(): ((string | undefined) | undefined) set __backing_count4(__backing_count4: (IProvideDecoratedVariable<(string | undefined)> | undefined)) get __backing_count4(): (IProvideDecoratedVariable<(string | undefined)> | undefined) + set __options_has_count4(__options_has_count4: (boolean | undefined)) + + get __options_has_count4(): (boolean | undefined) set count5(count5: ((string | undefined) | undefined)) get count5(): ((string | undefined) | undefined) set __backing_count5(__backing_count5: (IProvideDecoratedVariable<(string | undefined)> | undefined)) get __backing_count5(): (IProvideDecoratedVariable<(string | undefined)> | undefined) + set __options_has_count5(__options_has_count5: (boolean | undefined)) + + get __options_has_count5(): (boolean | undefined) set count6(count6: ((string | undefined) | undefined)) get count6(): ((string | undefined) | undefined) set __backing_count6(__backing_count6: (IProvideDecoratedVariable<(string | undefined)> | undefined)) get __backing_count6(): (IProvideDecoratedVariable<(string | undefined)> | undefined) + set __options_has_count6(__options_has_count6: (boolean | undefined)) + + get __options_has_count6(): (boolean | undefined) set count7(count7: ((string | undefined) | undefined)) get count7(): ((string | undefined) | undefined) set __backing_count7(__backing_count7: (IProvideDecoratedVariable<(string | undefined)> | undefined)) get __backing_count7(): (IProvideDecoratedVariable<(string | undefined)> | undefined) + set __options_has_count7(__options_has_count7: (boolean | undefined)) + + get __options_has_count7(): (boolean | undefined) } `; diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/provide-and-consume/provide-basic-type.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/provide-and-consume/provide-basic-type.test.ts index f0fefa008a5eea8e371c75f833f0bb7a0dd731df..b94cf597fec640bca023192461084a1d166a2ba0 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/provide-and-consume/provide-basic-type.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/provide-and-consume/provide-basic-type.test.ts @@ -44,7 +44,6 @@ import { IProvideDecoratedVariable as IProvideDecoratedVariable } from "arkui.st import { STATE_MGMT_FACTORY as STATE_MGMT_FACTORY } from "arkui.stateManagement.decorator"; - import { CustomComponent as CustomComponent } from "arkui.component.customComponent"; import { Component as Component } from "@ohos.arkui.component"; @@ -132,30 +131,45 @@ function main() {} set __backing_provideVar1(__backing_provideVar1: (IProvideDecoratedVariable | undefined)) get __backing_provideVar1(): (IProvideDecoratedVariable | undefined) + set __options_has_provideVar1(__options_has_provideVar1: (boolean | undefined)) + + get __options_has_provideVar1(): (boolean | undefined) set provideVar2(provideVar2: (number | undefined)) get provideVar2(): (number | undefined) set __backing_provideVar2(__backing_provideVar2: (IProvideDecoratedVariable | undefined)) get __backing_provideVar2(): (IProvideDecoratedVariable | undefined) + set __options_has_provideVar2(__options_has_provideVar2: (boolean | undefined)) + + get __options_has_provideVar2(): (boolean | undefined) set provideVar3(provideVar3: (boolean | undefined)) get provideVar3(): (boolean | undefined) set __backing_provideVar3(__backing_provideVar3: (IProvideDecoratedVariable | undefined)) get __backing_provideVar3(): (IProvideDecoratedVariable | undefined) + set __options_has_provideVar3(__options_has_provideVar3: (boolean | undefined)) + + get __options_has_provideVar3(): (boolean | undefined) set provideVar4(provideVar4: (undefined | undefined)) get provideVar4(): (undefined | undefined) set __backing_provideVar4(__backing_provideVar4: (IProvideDecoratedVariable | undefined)) get __backing_provideVar4(): (IProvideDecoratedVariable | undefined) + set __options_has_provideVar4(__options_has_provideVar4: (boolean | undefined)) + + get __options_has_provideVar4(): (boolean | undefined) set provideVar5(provideVar5: (null | undefined)) get provideVar5(): (null | undefined) set __backing_provideVar5(__backing_provideVar5: (IProvideDecoratedVariable | undefined)) get __backing_provideVar5(): (IProvideDecoratedVariable | undefined) + set __options_has_provideVar5(__options_has_provideVar5: (boolean | undefined)) + + get __options_has_provideVar5(): (boolean | undefined) } `; diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/provide-and-consume/provide-complex-type.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/provide-and-consume/provide-complex-type.test.ts index 15967cd3b6137333d3f93479961ee7d1baf90888..b3f5f162f254a581398d4d25c9900606113f404c 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/provide-and-consume/provide-complex-type.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/provide-and-consume/provide-complex-type.test.ts @@ -44,7 +44,6 @@ import { IProvideDecoratedVariable as IProvideDecoratedVariable } from "arkui.st import { STATE_MGMT_FACTORY as STATE_MGMT_FACTORY } from "arkui.stateManagement.decorator"; - import { CustomComponent as CustomComponent } from "arkui.component.customComponent"; import { Component as Component } from "@ohos.arkui.component"; @@ -293,72 +292,108 @@ final class PropType extends BaseEnum { set __backing_provideVar1(__backing_provideVar1: (IProvideDecoratedVariable | undefined)) get __backing_provideVar1(): (IProvideDecoratedVariable | undefined) + set __options_has_provideVar1(__options_has_provideVar1: (boolean | undefined)) + + get __options_has_provideVar1(): (boolean | undefined) set provideVar2(provideVar2: (Array | undefined)) get provideVar2(): (Array | undefined) set __backing_provideVar2(__backing_provideVar2: (IProvideDecoratedVariable> | undefined)) get __backing_provideVar2(): (IProvideDecoratedVariable> | undefined) + set __options_has_provideVar2(__options_has_provideVar2: (boolean | undefined)) + + get __options_has_provideVar2(): (boolean | undefined) set provideVar3(provideVar3: (PropType | undefined)) get provideVar3(): (PropType | undefined) set __backing_provideVar3(__backing_provideVar3: (IProvideDecoratedVariable | undefined)) get __backing_provideVar3(): (IProvideDecoratedVariable | undefined) + set __options_has_provideVar3(__options_has_provideVar3: (boolean | undefined)) + + get __options_has_provideVar3(): (boolean | undefined) set provideVar4(provideVar4: (Set | undefined)) get provideVar4(): (Set | undefined) set __backing_provideVar4(__backing_provideVar4: (IProvideDecoratedVariable> | undefined)) get __backing_provideVar4(): (IProvideDecoratedVariable> | undefined) + set __options_has_provideVar4(__options_has_provideVar4: (boolean | undefined)) + + get __options_has_provideVar4(): (boolean | undefined) set provideVar5(provideVar5: (Array | undefined)) get provideVar5(): (Array | undefined) set __backing_provideVar5(__backing_provideVar5: (IProvideDecoratedVariable> | undefined)) get __backing_provideVar5(): (IProvideDecoratedVariable> | undefined) + set __options_has_provideVar5(__options_has_provideVar5: (boolean | undefined)) + + get __options_has_provideVar5(): (boolean | undefined) set provideVar6(provideVar6: (Array | undefined)) get provideVar6(): (Array | undefined) set __backing_provideVar6(__backing_provideVar6: (IProvideDecoratedVariable> | undefined)) get __backing_provideVar6(): (IProvideDecoratedVariable> | undefined) + set __options_has_provideVar6(__options_has_provideVar6: (boolean | undefined)) + + get __options_has_provideVar6(): (boolean | undefined) set provideVar7(provideVar7: (Array | undefined)) get provideVar7(): (Array | undefined) set __backing_provideVar7(__backing_provideVar7: (IProvideDecoratedVariable> | undefined)) get __backing_provideVar7(): (IProvideDecoratedVariable> | undefined) + set __options_has_provideVar7(__options_has_provideVar7: (boolean | undefined)) + + get __options_has_provideVar7(): (boolean | undefined) set provideVar8(provideVar8: (((sr: string)=> void) | undefined)) get provideVar8(): (((sr: string)=> void) | undefined) set __backing_provideVar8(__backing_provideVar8: (IProvideDecoratedVariable<((sr: string)=> void)> | undefined)) get __backing_provideVar8(): (IProvideDecoratedVariable<((sr: string)=> void)> | undefined) + set __options_has_provideVar8(__options_has_provideVar8: (boolean | undefined)) + + get __options_has_provideVar8(): (boolean | undefined) set provideVar9(provideVar9: (Date | undefined)) get provideVar9(): (Date | undefined) set __backing_provideVar9(__backing_provideVar9: (IProvideDecoratedVariable | undefined)) get __backing_provideVar9(): (IProvideDecoratedVariable | undefined) + set __options_has_provideVar9(__options_has_provideVar9: (boolean | undefined)) + + get __options_has_provideVar9(): (boolean | undefined) set provideVar10(provideVar10: (Map | undefined)) get provideVar10(): (Map | undefined) set __backing_provideVar10(__backing_provideVar10: (IProvideDecoratedVariable> | undefined)) get __backing_provideVar10(): (IProvideDecoratedVariable> | undefined) + set __options_has_provideVar10(__options_has_provideVar10: (boolean | undefined)) + + get __options_has_provideVar10(): (boolean | undefined) set provideVar11(provideVar11: ((string | number) | undefined)) get provideVar11(): ((string | number) | undefined) set __backing_provideVar11(__backing_provideVar11: (IProvideDecoratedVariable<(string | number)> | undefined)) get __backing_provideVar11(): (IProvideDecoratedVariable<(string | number)> | undefined) + set __options_has_provideVar11(__options_has_provideVar11: (boolean | undefined)) + + get __options_has_provideVar11(): (boolean | undefined) set provideVar12(provideVar12: ((Set | Per) | undefined)) get provideVar12(): ((Set | Per) | undefined) set __backing_provideVar12(__backing_provideVar12: (IProvideDecoratedVariable<(Set | Per)> | undefined)) get __backing_provideVar12(): (IProvideDecoratedVariable<(Set | Per)> | undefined) + set __options_has_provideVar12(__options_has_provideVar12: (boolean | undefined)) + + get __options_has_provideVar12(): (boolean | undefined) } `; diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/provide-and-consume/provide-to-consume.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/provide-and-consume/provide-to-consume.test.ts index 3f01659b47fb9c3a5f348a576164543dcaf2a2a3..3a8839b91e15703959b75f9732e8f01014094fb1 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/provide-and-consume/provide-to-consume.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/provide-and-consume/provide-to-consume.test.ts @@ -80,16 +80,20 @@ import { Consume as Consume, Provide as Provide } from "@ohos.arkui.stateManagem @Component() export interface __Options_Child { num?: number; @Consume() __backing_num?: number; + __options_has_num?: boolean; str?: string; @Consume({value:"ss"}) __backing_str?: string; + __options_has_str?: boolean; } @Component() export interface __Options_Parent { num?: number; @Provide({alias:"num"}) __backing_num?: number; + __options_has_num?: boolean; str?: string; @Provide({alias:"ss"}) __backing_str?: string; + __options_has_str?: boolean; } `; @@ -111,8 +115,6 @@ import { Consume as Consume, Provide as Provide } from "@ohos.arkui.stateManagem function main() {} - - @Component() final struct Child extends CustomComponent { public __initializeStruct(initializers: (__Options_Child | undefined), @memo() content: ((()=> void) | undefined)): void { this.__backing_num = STATE_MGMT_FACTORY.makeConsume(this, "num", "num"); @@ -203,12 +205,18 @@ function main() {} set __backing_num(__backing_num: (IConsumeDecoratedVariable | undefined)) get __backing_num(): (IConsumeDecoratedVariable | undefined) + set __options_has_num(__options_has_num: (boolean | undefined)) + + get __options_has_num(): (boolean | undefined) set str(str: (string | undefined)) get str(): (string | undefined) set __backing_str(__backing_str: (IConsumeDecoratedVariable | undefined)) get __backing_str(): (IConsumeDecoratedVariable | undefined) + set __options_has_str(__options_has_str: (boolean | undefined)) + + get __options_has_str(): (boolean | undefined) } @@ -219,12 +227,18 @@ function main() {} set __backing_num(__backing_num: (IProvideDecoratedVariable | undefined)) get __backing_num(): (IProvideDecoratedVariable | undefined) + set __options_has_num(__options_has_num: (boolean | undefined)) + + get __options_has_num(): (boolean | undefined) set str(str: (string | undefined)) get str(): (string | undefined) set __backing_str(__backing_str: (IProvideDecoratedVariable | undefined)) get __backing_str(): (IProvideDecoratedVariable | undefined) + set __options_has_str(__options_has_str: (boolean | undefined)) + + get __options_has_str(): (boolean | undefined) } `; diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/provider-and-consumer/consumer-basic-type.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/provider-and-consumer/consumer-basic-type.test.ts index 7c4e62f2d14c537b47084e553251f1421b37a07e..a92a9bda9b38f23c72256ff3e172746e94358d8d 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/provider-and-consumer/consumer-basic-type.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/provider-and-consumer/consumer-basic-type.test.ts @@ -128,30 +128,45 @@ function main() {} set __backing_consumerVar1(__backing_consumerVar1: (IConsumerDecoratedVariable | undefined)) get __backing_consumerVar1(): (IConsumerDecoratedVariable | undefined) + set __options_has_consumerVar1(__options_has_consumerVar1: (boolean | undefined)) + + get __options_has_consumerVar1(): (boolean | undefined) set consumerVar2(consumerVar2: (number | undefined)) get consumerVar2(): (number | undefined) set __backing_consumerVar2(__backing_consumerVar2: (IConsumerDecoratedVariable | undefined)) get __backing_consumerVar2(): (IConsumerDecoratedVariable | undefined) + set __options_has_consumerVar2(__options_has_consumerVar2: (boolean | undefined)) + + get __options_has_consumerVar2(): (boolean | undefined) set consumerVar3(consumerVar3: (boolean | undefined)) get consumerVar3(): (boolean | undefined) set __backing_consumerVar3(__backing_consumerVar3: (IConsumerDecoratedVariable | undefined)) get __backing_consumerVar3(): (IConsumerDecoratedVariable | undefined) + set __options_has_consumerVar3(__options_has_consumerVar3: (boolean | undefined)) + + get __options_has_consumerVar3(): (boolean | undefined) set consumerVar4(consumerVar4: (undefined | undefined)) get consumerVar4(): (undefined | undefined) set __backing_consumerVar4(__backing_consumerVar4: (IConsumerDecoratedVariable | undefined)) get __backing_consumerVar4(): (IConsumerDecoratedVariable | undefined) + set __options_has_consumerVar4(__options_has_consumerVar4: (boolean | undefined)) + + get __options_has_consumerVar4(): (boolean | undefined) set consumerVar5(consumerVar5: (null | undefined)) get consumerVar5(): (null | undefined) set __backing_consumerVar5(__backing_consumerVar5: (IConsumerDecoratedVariable | undefined)) get __backing_consumerVar5(): (IConsumerDecoratedVariable | undefined) + set __options_has_consumerVar5(__options_has_consumerVar5: (boolean | undefined)) + + get __options_has_consumerVar5(): (boolean | undefined) } `; diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/provider-and-consumer/consumer-complex-type.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/provider-and-consumer/consumer-complex-type.test.ts index 809d7e3ceaa3ffb18937d406b9a528545549de57..aa2a9cc552c0095bda19e91d5317a7c31524d780 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/provider-and-consumer/consumer-complex-type.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/provider-and-consumer/consumer-complex-type.test.ts @@ -271,66 +271,99 @@ final class StateType extends BaseEnum { set __backing_paramVar1(__backing_paramVar1: (IConsumerDecoratedVariable | undefined)) get __backing_paramVar1(): (IConsumerDecoratedVariable | undefined) + set __options_has_paramVar1(__options_has_paramVar1: (boolean | undefined)) + + get __options_has_paramVar1(): (boolean | undefined) set paramVar2(paramVar2: (Array | undefined)) get paramVar2(): (Array | undefined) set __backing_paramVar2(__backing_paramVar2: (IConsumerDecoratedVariable> | undefined)) get __backing_paramVar2(): (IConsumerDecoratedVariable> | undefined) + set __options_has_paramVar2(__options_has_paramVar2: (boolean | undefined)) + + get __options_has_paramVar2(): (boolean | undefined) set paramVar3(paramVar3: (StateType | undefined)) get paramVar3(): (StateType | undefined) set __backing_paramVar3(__backing_paramVar3: (IConsumerDecoratedVariable | undefined)) get __backing_paramVar3(): (IConsumerDecoratedVariable | undefined) + set __options_has_paramVar3(__options_has_paramVar3: (boolean | undefined)) + + get __options_has_paramVar3(): (boolean | undefined) set paramVar4(paramVar4: (Set | undefined)) get paramVar4(): (Set | undefined) set __backing_paramVar4(__backing_paramVar4: (IConsumerDecoratedVariable> | undefined)) get __backing_paramVar4(): (IConsumerDecoratedVariable> | undefined) + set __options_has_paramVar4(__options_has_paramVar4: (boolean | undefined)) + + get __options_has_paramVar4(): (boolean | undefined) set paramVar5(paramVar5: (Array | undefined)) get paramVar5(): (Array | undefined) set __backing_paramVar5(__backing_paramVar5: (IConsumerDecoratedVariable> | undefined)) get __backing_paramVar5(): (IConsumerDecoratedVariable> | undefined) + set __options_has_paramVar5(__options_has_paramVar5: (boolean | undefined)) + + get __options_has_paramVar5(): (boolean | undefined) set paramVar6(paramVar6: (Array | undefined)) get paramVar6(): (Array | undefined) set __backing_paramVar6(__backing_paramVar6: (IConsumerDecoratedVariable> | undefined)) get __backing_paramVar6(): (IConsumerDecoratedVariable> | undefined) + set __options_has_paramVar6(__options_has_paramVar6: (boolean | undefined)) + + get __options_has_paramVar6(): (boolean | undefined) set paramVar7(paramVar7: (Array | undefined)) get paramVar7(): (Array | undefined) set __backing_paramVar7(__backing_paramVar7: (IConsumerDecoratedVariable> | undefined)) get __backing_paramVar7(): (IConsumerDecoratedVariable> | undefined) + set __options_has_paramVar7(__options_has_paramVar7: (boolean | undefined)) + + get __options_has_paramVar7(): (boolean | undefined) set paramVar9(paramVar9: (Date | undefined)) get paramVar9(): (Date | undefined) set __backing_paramVar9(__backing_paramVar9: (IConsumerDecoratedVariable | undefined)) get __backing_paramVar9(): (IConsumerDecoratedVariable | undefined) + set __options_has_paramVar9(__options_has_paramVar9: (boolean | undefined)) + + get __options_has_paramVar9(): (boolean | undefined) set paramVar10(paramVar10: (Map | undefined)) get paramVar10(): (Map | undefined) set __backing_paramVar10(__backing_paramVar10: (IConsumerDecoratedVariable> | undefined)) get __backing_paramVar10(): (IConsumerDecoratedVariable> | undefined) + set __options_has_paramVar10(__options_has_paramVar10: (boolean | undefined)) + + get __options_has_paramVar10(): (boolean | undefined) set paramVar11(paramVar11: ((string | number) | undefined)) get paramVar11(): ((string | number) | undefined) set __backing_paramVar11(__backing_paramVar11: (IConsumerDecoratedVariable<(string | number)> | undefined)) get __backing_paramVar11(): (IConsumerDecoratedVariable<(string | number)> | undefined) + set __options_has_paramVar11(__options_has_paramVar11: (boolean | undefined)) + + get __options_has_paramVar11(): (boolean | undefined) set paramVar12(paramVar12: ((Set | Per) | undefined)) get paramVar12(): ((Set | Per) | undefined) set __backing_paramVar12(__backing_paramVar12: (IConsumerDecoratedVariable<(Set | Per)> | undefined)) get __backing_paramVar12(): (IConsumerDecoratedVariable<(Set | Per)> | undefined) + set __options_has_paramVar12(__options_has_paramVar12: (boolean | undefined)) + + get __options_has_paramVar12(): (boolean | undefined) } `; diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/provider-and-consumer/provider-basic-type.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/provider-and-consumer/provider-basic-type.test.ts index 9943acaee83f7f67d0c7fb53e4f25bcbf98c386c..b47aef4a9f720846c426c5eba382b7dd15511df2 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/provider-and-consumer/provider-basic-type.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/provider-and-consumer/provider-basic-type.test.ts @@ -128,30 +128,45 @@ function main() {} set __backing_providerVar1(__backing_providerVar1: (IProviderDecoratedVariable | undefined)) get __backing_providerVar1(): (IProviderDecoratedVariable | undefined) + set __options_has_providerVar1(__options_has_providerVar1: (boolean | undefined)) + + get __options_has_providerVar1(): (boolean | undefined) set providerVar2(providerVar2: (number | undefined)) get providerVar2(): (number | undefined) set __backing_providerVar2(__backing_providerVar2: (IProviderDecoratedVariable | undefined)) get __backing_providerVar2(): (IProviderDecoratedVariable | undefined) + set __options_has_providerVar2(__options_has_providerVar2: (boolean | undefined)) + + get __options_has_providerVar2(): (boolean | undefined) set providerVar3(providerVar3: (boolean | undefined)) get providerVar3(): (boolean | undefined) set __backing_providerVar3(__backing_providerVar3: (IProviderDecoratedVariable | undefined)) get __backing_providerVar3(): (IProviderDecoratedVariable | undefined) + set __options_has_providerVar3(__options_has_providerVar3: (boolean | undefined)) + + get __options_has_providerVar3(): (boolean | undefined) set providerVar4(providerVar4: (undefined | undefined)) get providerVar4(): (undefined | undefined) set __backing_providerVar4(__backing_providerVar4: (IProviderDecoratedVariable | undefined)) get __backing_providerVar4(): (IProviderDecoratedVariable | undefined) + set __options_has_providerVar4(__options_has_providerVar4: (boolean | undefined)) + + get __options_has_providerVar4(): (boolean | undefined) set providerVar5(providerVar5: (null | undefined)) get providerVar5(): (null | undefined) set __backing_providerVar5(__backing_providerVar5: (IProviderDecoratedVariable | undefined)) get __backing_providerVar5(): (IProviderDecoratedVariable | undefined) + set __options_has_providerVar5(__options_has_providerVar5: (boolean | undefined)) + + get __options_has_providerVar5(): (boolean | undefined) } `; diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/provider-and-consumer/provider-complex-type.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/provider-and-consumer/provider-complex-type.test.ts index 2a953691a71a49446d0df769073081cbee304b71..20ed1c320b166e065555309c9f4589d13759b75d 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/provider-and-consumer/provider-complex-type.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/provider-and-consumer/provider-complex-type.test.ts @@ -271,66 +271,99 @@ final class StateType extends BaseEnum { set __backing_paramVar1(__backing_paramVar1: (IProviderDecoratedVariable | undefined)) get __backing_paramVar1(): (IProviderDecoratedVariable | undefined) + set __options_has_paramVar1(__options_has_paramVar1: (boolean | undefined)) + + get __options_has_paramVar1(): (boolean | undefined) set paramVar2(paramVar2: (Array | undefined)) get paramVar2(): (Array | undefined) set __backing_paramVar2(__backing_paramVar2: (IProviderDecoratedVariable> | undefined)) get __backing_paramVar2(): (IProviderDecoratedVariable> | undefined) + set __options_has_paramVar2(__options_has_paramVar2: (boolean | undefined)) + + get __options_has_paramVar2(): (boolean | undefined) set paramVar3(paramVar3: (StateType | undefined)) get paramVar3(): (StateType | undefined) set __backing_paramVar3(__backing_paramVar3: (IProviderDecoratedVariable | undefined)) get __backing_paramVar3(): (IProviderDecoratedVariable | undefined) + set __options_has_paramVar3(__options_has_paramVar3: (boolean | undefined)) + + get __options_has_paramVar3(): (boolean | undefined) set paramVar4(paramVar4: (Set | undefined)) get paramVar4(): (Set | undefined) set __backing_paramVar4(__backing_paramVar4: (IProviderDecoratedVariable> | undefined)) get __backing_paramVar4(): (IProviderDecoratedVariable> | undefined) + set __options_has_paramVar4(__options_has_paramVar4: (boolean | undefined)) + + get __options_has_paramVar4(): (boolean | undefined) set paramVar5(paramVar5: (Array | undefined)) get paramVar5(): (Array | undefined) set __backing_paramVar5(__backing_paramVar5: (IProviderDecoratedVariable> | undefined)) get __backing_paramVar5(): (IProviderDecoratedVariable> | undefined) + set __options_has_paramVar5(__options_has_paramVar5: (boolean | undefined)) + + get __options_has_paramVar5(): (boolean | undefined) set paramVar6(paramVar6: (Array | undefined)) get paramVar6(): (Array | undefined) set __backing_paramVar6(__backing_paramVar6: (IProviderDecoratedVariable> | undefined)) get __backing_paramVar6(): (IProviderDecoratedVariable> | undefined) + set __options_has_paramVar6(__options_has_paramVar6: (boolean | undefined)) + + get __options_has_paramVar6(): (boolean | undefined) set paramVar7(paramVar7: (Array | undefined)) get paramVar7(): (Array | undefined) set __backing_paramVar7(__backing_paramVar7: (IProviderDecoratedVariable> | undefined)) get __backing_paramVar7(): (IProviderDecoratedVariable> | undefined) + set __options_has_paramVar7(__options_has_paramVar7: (boolean | undefined)) + + get __options_has_paramVar7(): (boolean | undefined) set paramVar9(paramVar9: (Date | undefined)) get paramVar9(): (Date | undefined) set __backing_paramVar9(__backing_paramVar9: (IProviderDecoratedVariable | undefined)) get __backing_paramVar9(): (IProviderDecoratedVariable | undefined) + set __options_has_paramVar9(__options_has_paramVar9: (boolean | undefined)) + + get __options_has_paramVar9(): (boolean | undefined) set paramVar10(paramVar10: (Map | undefined)) get paramVar10(): (Map | undefined) set __backing_paramVar10(__backing_paramVar10: (IProviderDecoratedVariable> | undefined)) get __backing_paramVar10(): (IProviderDecoratedVariable> | undefined) + set __options_has_paramVar10(__options_has_paramVar10: (boolean | undefined)) + + get __options_has_paramVar10(): (boolean | undefined) set paramVar11(paramVar11: ((string | number) | undefined)) get paramVar11(): ((string | number) | undefined) set __backing_paramVar11(__backing_paramVar11: (IProviderDecoratedVariable<(string | number)> | undefined)) get __backing_paramVar11(): (IProviderDecoratedVariable<(string | number)> | undefined) + set __options_has_paramVar11(__options_has_paramVar11: (boolean | undefined)) + + get __options_has_paramVar11(): (boolean | undefined) set paramVar12(paramVar12: ((Set | Per) | undefined)) get paramVar12(): ((Set | Per) | undefined) set __backing_paramVar12(__backing_paramVar12: (IProviderDecoratedVariable<(Set | Per)> | undefined)) get __backing_paramVar12(): (IProviderDecoratedVariable<(Set | Per)> | undefined) + set __options_has_paramVar12(__options_has_paramVar12: (boolean | undefined)) + + get __options_has_paramVar12(): (boolean | undefined) } `; diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/provider-and-consumer/provider-to-consumer.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/provider-and-consumer/provider-to-consumer.test.ts index 89a5a701f9eb7a019ef1711eee2b086039e73c25..88ebc8c5bd478e0204127be5a46bac4e21ae7cc4 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/provider-and-consumer/provider-to-consumer.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/provider-and-consumer/provider-to-consumer.test.ts @@ -72,8 +72,6 @@ const data: Array = [new User("Json", 10), new User("Eric", 15)]; function main() {} -data = [new User("Json", 10), new User("Eric", 15)]; - @ObservedV2() class User implements IObservedObject, ISubscribedWatches { @JSONStringifyIgnore() private subscribedWatches: ISubscribedWatches = STATE_MGMT_FACTORY.makeSubscribedWatches(); @@ -231,6 +229,9 @@ data = [new User("Json", 10), new User("Eric", 15)]; set __backing_users(__backing_users: (IProviderDecoratedVariable> | undefined)) get __backing_users(): (IProviderDecoratedVariable> | undefined) + set __options_has_users(__options_has_users: (boolean | undefined)) + + get __options_has_users(): (boolean | undefined) } @@ -241,6 +242,9 @@ data = [new User("Json", 10), new User("Eric", 15)]; set __backing_users(__backing_users: (IConsumerDecoratedVariable> | undefined)) get __backing_users(): (IConsumerDecoratedVariable> | undefined) + set __options_has_users(__options_has_users: (boolean | undefined)) + + get __options_has_users(): (boolean | undefined) } `; diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/require/basic-require.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/require/basic-require.test.ts index a7892cf9f6c32f8652f69f650cce4c6091ccd0ea..7148daa6fc3e4cc654ecb1aab590fe1a2e0b1838 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/require/basic-require.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/require/basic-require.test.ts @@ -41,18 +41,27 @@ const expectedParsedScript: string = ` import { CustomComponentV2 as CustomComponentV2 } from "arkui.component.customComponent"; import { CustomComponent as CustomComponent } from "arkui.component.customComponent"; import { Component as Component, ComponentV2 as ComponentV2, BuilderParam as BuilderParam } from "@ohos.arkui.component"; -import { State as State, Require as Require, Prop as Prop, Provide as Provide, Param as Param } from "@ohos.arkui.stateManagement"; +import { State as State, Require as Require, PropRef as PropRef, Provide as Provide, Param as Param } from "@ohos.arkui.stateManagement"; @Component() final struct MyStateSample extends CustomComponent { public hello: string = "hello"; + @State() public state1: boolean = false; + @Require() public select100!: string; + @Require() @State() public select0!: number; + @Require() @State() public select3?: (number | null); + @Require() @State() public select4?: undefined; - @Require() @Prop() public select1!: string; + + @Require() @PropRef() public select1!: string; + @Require() @Provide({alias:"15"}) public select2!: string[]; + @Require() @Provide({alias:"t"}) public select6?: (string[] | undefined | string); + @Require() @BuilderParam() public builder!: (()=> void); public build() {} @@ -72,28 +81,39 @@ import { State as State, Require as Require, Prop as Prop, Provide as Provide, P @Component() export interface __Options_MyStateSample { hello?: string; + __options_has_hello?: boolean; state1?: boolean; @State() __backing_state1?: boolean; + __options_has_state1?: boolean; select100?: string; + __options_has_select100?: boolean; select0?: number; @Require() @State() __backing_select0?: number; + __options_has_select0?: boolean; select3?: (number | null); @Require() @State() __backing_select3?: (number | null); + __options_has_select3?: boolean; select4?: undefined; @Require() @State() __backing_select4?: undefined; + __options_has_select4?: boolean; select1?: string; - @Require() @Prop() __backing_select1?: string; + @Require() @PropRef() __backing_select1?: string; + __options_has_select1?: boolean; select2?: string[]; @Require() @Provide({alias:"15"}) __backing_select2?: string[]; + __options_has_select2?: boolean; select6?: (string[] | undefined | string); @Require() @Provide({alias:"t"}) __backing_select6?: (string[] | undefined | string); + __options_has_select6?: boolean; @BuilderParam() builder?: (()=> void); + __options_has_builder?: boolean; } @ComponentV2() export interface __Options_V2222 { select1?: string; @Require() @Param() __backing_select1?: string; + __options_has_select1?: boolean; } `; @@ -101,14 +121,14 @@ import { State as State, Require as Require, Prop as Prop, Provide as Provide, P const expectedCheckedScript: string = ` import { IParamDecoratedVariable as IParamDecoratedVariable } from "arkui.stateManagement.decorator"; import { IProvideDecoratedVariable as IProvideDecoratedVariable } from "arkui.stateManagement.decorator"; -import { IPropDecoratedVariable as IPropDecoratedVariable } from "arkui.stateManagement.decorator"; +import { IPropRefDecoratedVariable as IPropRefDecoratedVariable } from "arkui.stateManagement.decorator"; import { STATE_MGMT_FACTORY as STATE_MGMT_FACTORY } from "arkui.stateManagement.decorator"; import { IStateDecoratedVariable as IStateDecoratedVariable } from "arkui.stateManagement.decorator"; import { memo as memo } from "arkui.stateManagement.runtime"; import { CustomComponentV2 as CustomComponentV2 } from "arkui.component.customComponent"; import { CustomComponent as CustomComponent } from "arkui.component.customComponent"; import { Component as Component, ComponentV2 as ComponentV2, BuilderParam as BuilderParam } from "@ohos.arkui.component"; -import { State as State, Require as Require, Prop as Prop, Provide as Provide, Param as Param } from "@ohos.arkui.stateManagement"; +import { State as State, Require as Require, PropRef as PropRef, Provide as Provide, Param as Param } from "@ohos.arkui.stateManagement"; function main() {} @@ -123,16 +143,16 @@ function main() {} this.__backing_select0 = STATE_MGMT_FACTORY.makeState(this, "select0", (initializers!.select0 as number)); this.__backing_select3 = STATE_MGMT_FACTORY.makeState<(number | null)>(this, "select3", (initializers!.select3 as (number | null))); this.__backing_select4 = STATE_MGMT_FACTORY.makeState(this, "select4", (initializers!.select4 as undefined)); - this.__backing_select1 = STATE_MGMT_FACTORY.makeProp(this, "select1", (initializers!.select1 as string)); + this.__backing_select1 = STATE_MGMT_FACTORY.makePropRef(this, "select1", (initializers!.select1 as string)); this.__backing_select2 = STATE_MGMT_FACTORY.makeProvide>(this, "select2", "15", (initializers!.select2 as Array), false); this.__backing_select6 = STATE_MGMT_FACTORY.makeProvide<(Array | undefined | string)>(this, "select6", "t", (initializers!.select6 as (Array | undefined | string)), false); - this.__backing_builder = ((((({let gensym___57081607 = initializers; - (((gensym___57081607) == (null)) ? undefined : gensym___57081607.builder)})) ?? (content))) ?? (undefined)) + this.__backing_builder = ((((({let gensym___63603867 = initializers; + (((gensym___63603867) == (null)) ? undefined : gensym___63603867.builder)})) ?? (content))) ?? (undefined)) } public __updateStruct(initializers: (__Options_MyStateSample | undefined)): void { - if (((({let gensym___171969630 = initializers; - (((gensym___171969630) == (null)) ? undefined : gensym___171969630.select1)})) !== (undefined))) { + if (({let gensym___77985515 = initializers; + (((gensym___77985515) == (null)) ? undefined : gensym___77985515.__options_has_select1)})) { this.__backing_select1!.update((initializers!.select1 as string)); } } @@ -197,7 +217,7 @@ function main() {} this.__backing_select4!.set(value); } - private __backing_select1?: IPropDecoratedVariable; + private __backing_select1?: IPropRefDecoratedVariable; public get select1(): string { return this.__backing_select1!.get(); @@ -249,8 +269,8 @@ function main() {} } public __updateStruct(initializers: (__Options_V2222 | undefined)): void { - if (((({let gensym___155019449 = initializers; - (((gensym___155019449) == (null)) ? undefined : gensym___155019449.select1)})) !== (undefined))) { + if (({let gensym___8595130 = initializers; + (((gensym___8595130) == (null)) ? undefined : gensym___8595130.__options_has_select1)})) { this.__backing_select1!.update((initializers!.select1 as string)); } } @@ -271,54 +291,84 @@ function main() {} set hello(hello: (string | undefined)) get hello(): (string | undefined) + set __options_has_hello(__options_has_hello: (boolean | undefined)) + + get __options_has_hello(): (boolean | undefined) set state1(state1: (boolean | undefined)) get state1(): (boolean | undefined) set __backing_state1(__backing_state1: (IStateDecoratedVariable | undefined)) get __backing_state1(): (IStateDecoratedVariable | undefined) + set __options_has_state1(__options_has_state1: (boolean | undefined)) + + get __options_has_state1(): (boolean | undefined) set select100(select100: (string | undefined)) get select100(): (string | undefined) + set __options_has_select100(__options_has_select100: (boolean | undefined)) + + get __options_has_select100(): (boolean | undefined) set select0(select0: (number | undefined)) get select0(): (number | undefined) @Require() set __backing_select0(__backing_select0: (IStateDecoratedVariable | undefined)) @Require() get __backing_select0(): (IStateDecoratedVariable | undefined) + set __options_has_select0(__options_has_select0: (boolean | undefined)) + + get __options_has_select0(): (boolean | undefined) set select3(select3: ((number | null) | undefined)) get select3(): ((number | null) | undefined) @Require() set __backing_select3(__backing_select3: (IStateDecoratedVariable<(number | null)> | undefined)) @Require() get __backing_select3(): (IStateDecoratedVariable<(number | null)> | undefined) + set __options_has_select3(__options_has_select3: (boolean | undefined)) + + get __options_has_select3(): (boolean | undefined) set select4(select4: (undefined | undefined)) get select4(): (undefined | undefined) @Require() set __backing_select4(__backing_select4: (IStateDecoratedVariable | undefined)) @Require() get __backing_select4(): (IStateDecoratedVariable | undefined) + set __options_has_select4(__options_has_select4: (boolean | undefined)) + + get __options_has_select4(): (boolean | undefined) set select1(select1: (string | undefined)) get select1(): (string | undefined) - @Require() set __backing_select1(__backing_select1: (IPropDecoratedVariable | undefined)) + @Require() set __backing_select1(__backing_select1: (IPropRefDecoratedVariable | undefined)) - @Require() get __backing_select1(): (IPropDecoratedVariable | undefined) + @Require() get __backing_select1(): (IPropRefDecoratedVariable | undefined) + set __options_has_select1(__options_has_select1: (boolean | undefined)) + + get __options_has_select1(): (boolean | undefined) set select2(select2: (Array | undefined)) get select2(): (Array | undefined) @Require() set __backing_select2(__backing_select2: (IProvideDecoratedVariable> | undefined)) @Require() get __backing_select2(): (IProvideDecoratedVariable> | undefined) + set __options_has_select2(__options_has_select2: (boolean | undefined)) + + get __options_has_select2(): (boolean | undefined) set select6(select6: ((Array | undefined | string) | undefined)) get select6(): ((Array | undefined | string) | undefined) @Require() set __backing_select6(__backing_select6: (IProvideDecoratedVariable<(Array | undefined | string)> | undefined)) @Require() get __backing_select6(): (IProvideDecoratedVariable<(Array | undefined | string)> | undefined) + set __options_has_select6(__options_has_select6: (boolean | undefined)) + + get __options_has_select6(): (boolean | undefined) set builder(builder: (@memo() (()=> void) | undefined)) get builder(): (@memo() (()=> void) | undefined) + set __options_has_builder(__options_has_builder: (boolean | undefined)) + + get __options_has_builder(): (boolean | undefined) } @@ -329,6 +379,9 @@ function main() {} @Require() set __backing_select1(__backing_select1: (IParamDecoratedVariable | undefined)) @Require() get __backing_select1(): (IParamDecoratedVariable | undefined) + set __options_has_select1(__options_has_select1: (boolean | undefined)) + + get __options_has_select1(): (boolean | undefined) } `; diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/resource/resource-in-build.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/resource/resource-in-build.test.ts index a0e46261746cfc5dd43c78990fe2785daf27d699..e2e5de1e9bfadc095f0e248dd6b3395e5db87993 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/resource/resource-in-build.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/resource/resource-in-build.test.ts @@ -151,11 +151,24 @@ function main() {} @Component() export interface __Options_ResourceComponent { set str1(str1: (string | undefined)) + get str1(): (string | undefined) + set __options_has_str1(__options_has_str1: (boolean | undefined)) + + get __options_has_str1(): (boolean | undefined) set str2(str2: (string | undefined)) + get str2(): (string | undefined) + set __options_has_str2(__options_has_str2: (boolean | undefined)) + + get __options_has_str2(): (boolean | undefined) set numbers(numbers: (Array | undefined)) + get numbers(): (Array | undefined) + set __options_has_numbers(__options_has_numbers: (boolean | undefined)) + + get __options_has_numbers(): (boolean | undefined) + } `; diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/resource/resource-in-property.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/resource/resource-in-property.test.ts index 8856ce40285a8d5f668d83a9c6439a564614d1e4..ca6dc2ffe61becbf71fedae3a7b71dff69d0f2c1 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/resource/resource-in-property.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/resource/resource-in-property.test.ts @@ -85,9 +85,18 @@ i = _r(16777216, 10003, "com.example.mock", "entry"); @Component() export interface __Options_ResourceComponent { set str(str: (Resource | undefined)) + get str(): (Resource | undefined) + set __options_has_str(__options_has_str: (boolean | undefined)) + + get __options_has_str(): (boolean | undefined) set icon(icon: (Resource | undefined)) + get icon(): (Resource | undefined) + set __options_has_icon(__options_has_icon: (boolean | undefined)) + + get __options_has_icon(): (boolean | undefined) + } `; diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/reusable/reusable-basic.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/reusable/reusable-basic.test.ts index 1414b3d22ba530e1e74cd4b4f29d6e62fb120e87..733f63063fcfc9167f5bfe0013fcf3d04f463871 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/reusable/reusable-basic.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/reusable/reusable-basic.test.ts @@ -42,21 +42,18 @@ import { IStateDecoratedVariable as IStateDecoratedVariable } from "arkui.stateM import { STATE_MGMT_FACTORY as STATE_MGMT_FACTORY } from "arkui.stateManagement.decorator"; -import { IPropDecoratedVariable as IPropDecoratedVariable } from "arkui.stateManagement.decorator"; +import { IPropRefDecoratedVariable as IPropRefDecoratedVariable } from "arkui.stateManagement.decorator"; import { memo as memo } from "arkui.stateManagement.runtime"; - import { CustomComponent as CustomComponent } from "arkui.component.customComponent"; import { Component as Component, Reusable as Reusable } from "@ohos.arkui.component"; -import { State as State, Prop as Prop } from "@ohos.arkui.stateManagement"; +import { State as State, PropRef as PropRef } from "@ohos.arkui.stateManagement"; function main() {} - - @Component() final struct MyStateSample extends CustomComponent { public __initializeStruct(initializers: (__Options_MyStateSample | undefined), @memo() content: ((()=> void) | undefined)): void {} @@ -66,7 +63,8 @@ function main() {} Child._instantiateImpl(undefined, (() => { return new Child(); }), { - num: 5, + num1: 5, + __options_has_num1: true, }, "Child", undefined); } @@ -76,15 +74,15 @@ function main() {} @Component() @Reusable() final struct Child extends CustomComponent { public __initializeStruct(initializers: (__Options_Child | undefined), @memo() content: ((()=> void) | undefined)): void { - this.__backing_num = STATE_MGMT_FACTORY.makeProp(this, "num", ((({let gensym___83257243 = initializers; + this.__backing_num = STATE_MGMT_FACTORY.makePropRef(this, "num", ((({let gensym___83257243 = initializers; (((gensym___83257243) == (null)) ? undefined : gensym___83257243.num)})) ?? (1))); this.__backing_num1 = STATE_MGMT_FACTORY.makeState(this, "num1", ((({let gensym___24398512 = initializers; (((gensym___24398512) == (null)) ? undefined : gensym___24398512.num1)})) ?? (2))); } public __updateStruct(initializers: (__Options_Child | undefined)): void { - if (((({let gensym___108716469 = initializers; - (((gensym___108716469) == (null)) ? undefined : gensym___108716469.num)})) !== (undefined))) { + if (({let gensym___111600432 = initializers; + (((gensym___111600432) == (null)) ? undefined : gensym___111600432.__options_has_num)})) { this.__backing_num!.update((initializers!.num as number)); } } @@ -97,7 +95,7 @@ function main() {} }; } - private __backing_num?: IPropDecoratedVariable; + private __backing_num?: IPropRefDecoratedVariable; public get num(): number { return this.__backing_num!.get(); @@ -131,15 +129,21 @@ function main() {} set num(num: (number | undefined)) get num(): (number | undefined) - set __backing_num(__backing_num: (IPropDecoratedVariable | undefined)) + set __backing_num(__backing_num: (IPropRefDecoratedVariable | undefined)) - get __backing_num(): (IPropDecoratedVariable | undefined) + get __backing_num(): (IPropRefDecoratedVariable | undefined) + set __options_has_num(__options_has_num: (boolean | undefined)) + + get __options_has_num(): (boolean | undefined) set num1(num1: (number | undefined)) get num1(): (number | undefined) set __backing_num1(__backing_num1: (IStateDecoratedVariable | undefined)) get __backing_num1(): (IStateDecoratedVariable | undefined) + set __options_has_num1(__options_has_num1: (boolean | undefined)) + + get __options_has_num1(): (boolean | undefined) } `; diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/reusable/reusable-complex.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/reusable/reusable-complex.test.ts index 8c3c455dcfeb61496b5271feba853cb28a79e65c..2e3a74cfc9b6beed5d129dad97f8c41540783235 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/reusable/reusable-complex.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/reusable/reusable-complex.test.ts @@ -38,7 +38,6 @@ const reusableTransform: Plugins = { const pluginTester = new PluginTester('test complex reusable', buildConfig); const expectedScript: string = ` - import { TextAttribute as TextAttribute } from "arkui.component.text"; import { STATE_MGMT_FACTORY as STATE_MGMT_FACTORY } from "arkui.stateManagement.decorator"; @@ -123,6 +122,7 @@ class Message { return new Child(); }), { message: new Message("Child"), + __options_has_message: true, }, "Child", undefined); })); } @@ -159,9 +159,7 @@ class Message { this.__backing_message!.set(value); } - public aboutToReuse(params: Record) { - console.info("Recycle ====Child=="); - } + public aboutToReuse(params: Record) {} @memo() public build() { Column(@memo() ((instance: ColumnAttribute): void => { @@ -186,6 +184,9 @@ class Message { set __backing_display(__backing_display: (IStateDecoratedVariable | undefined)) get __backing_display(): (IStateDecoratedVariable | undefined) + set __options_has_display(__options_has_display: (boolean | undefined)) + + get __options_has_display(): (boolean | undefined) } @@ -196,6 +197,9 @@ class Message { set __backing_message(__backing_message: (IStateDecoratedVariable | undefined)) get __backing_message(): (IStateDecoratedVariable | undefined) + set __options_has_message(__options_has_message: (boolean | undefined)) + + get __options_has_message(): (boolean | undefined) } diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/state/state-basic-type.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/state/state-basic-type.test.ts index b354198ae070d1e180cd0585b4ce56113dd6113d..5ef1bad98cbaddb260187ded025c9776872c05ea 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/state/state-basic-type.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/state/state-basic-type.test.ts @@ -38,14 +38,12 @@ const parsedTransform: Plugins = { }; const expectedScript: string = ` - import { memo as memo } from "arkui.stateManagement.runtime"; import { STATE_MGMT_FACTORY as STATE_MGMT_FACTORY } from "arkui.stateManagement.decorator"; import { IStateDecoratedVariable as IStateDecoratedVariable } from "arkui.stateManagement.decorator"; - import { CustomComponent as CustomComponent } from "arkui.component.customComponent"; import { Component as Component } from "@ohos.arkui.component"; @@ -54,8 +52,6 @@ import { State as State } from "@ohos.arkui.stateManagement"; function main() {} - - @Component() final struct Parent extends CustomComponent { public __initializeStruct(initializers: (__Options_Parent | undefined), @memo() content: ((()=> void) | undefined)): void { this.__backing_stateVar1 = STATE_MGMT_FACTORY.makeState(this, "stateVar1", ((({let gensym___213853607 = initializers; @@ -135,30 +131,45 @@ function main() {} set __backing_stateVar1(__backing_stateVar1: (IStateDecoratedVariable | undefined)) get __backing_stateVar1(): (IStateDecoratedVariable | undefined) + set __options_has_stateVar1(__options_has_stateVar1: (boolean | undefined)) + + get __options_has_stateVar1(): (boolean | undefined) set stateVar2(stateVar2: (number | undefined)) get stateVar2(): (number | undefined) set __backing_stateVar2(__backing_stateVar2: (IStateDecoratedVariable | undefined)) get __backing_stateVar2(): (IStateDecoratedVariable | undefined) + set __options_has_stateVar2(__options_has_stateVar2: (boolean | undefined)) + + get __options_has_stateVar2(): (boolean | undefined) set stateVar3(stateVar3: (boolean | undefined)) get stateVar3(): (boolean | undefined) set __backing_stateVar3(__backing_stateVar3: (IStateDecoratedVariable | undefined)) get __backing_stateVar3(): (IStateDecoratedVariable | undefined) + set __options_has_stateVar3(__options_has_stateVar3: (boolean | undefined)) + + get __options_has_stateVar3(): (boolean | undefined) set stateVar4(stateVar4: (undefined | undefined)) get stateVar4(): (undefined | undefined) set __backing_stateVar4(__backing_stateVar4: (IStateDecoratedVariable | undefined)) get __backing_stateVar4(): (IStateDecoratedVariable | undefined) + set __options_has_stateVar4(__options_has_stateVar4: (boolean | undefined)) + + get __options_has_stateVar4(): (boolean | undefined) set stateVar5(stateVar5: (null | undefined)) get stateVar5(): (null | undefined) set __backing_stateVar5(__backing_stateVar5: (IStateDecoratedVariable | undefined)) get __backing_stateVar5(): (IStateDecoratedVariable | undefined) + set __options_has_stateVar5(__options_has_stateVar5: (boolean | undefined)) + + get __options_has_stateVar5(): (boolean | undefined) } `; diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/state/state-complex-type.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/state/state-complex-type.test.ts index 40f1f71d93a8d5f551e308ecdef9da2bf22c4e5d..920170b7e64b596a073b9977f1fc3a3d19975907 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/state/state-complex-type.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/state/state-complex-type.test.ts @@ -44,7 +44,6 @@ import { STATE_MGMT_FACTORY as STATE_MGMT_FACTORY } from "arkui.stateManagement. import { IStateDecoratedVariable as IStateDecoratedVariable } from "arkui.stateManagement.decorator"; - import { CustomComponent as CustomComponent } from "arkui.component.customComponent"; import { Component as Component } from "@ohos.arkui.component"; @@ -293,75 +292,110 @@ final class StateType extends BaseEnum { set __backing_stateVar1(__backing_stateVar1: (IStateDecoratedVariable | undefined)) get __backing_stateVar1(): (IStateDecoratedVariable | undefined) + set __options_has_stateVar1(__options_has_stateVar1: (boolean | undefined)) + + get __options_has_stateVar1(): (boolean | undefined) set stateVar2(stateVar2: (Array | undefined)) get stateVar2(): (Array | undefined) set __backing_stateVar2(__backing_stateVar2: (IStateDecoratedVariable> | undefined)) get __backing_stateVar2(): (IStateDecoratedVariable> | undefined) + set __options_has_stateVar2(__options_has_stateVar2: (boolean | undefined)) + + get __options_has_stateVar2(): (boolean | undefined) set stateVar3(stateVar3: (StateType | undefined)) get stateVar3(): (StateType | undefined) set __backing_stateVar3(__backing_stateVar3: (IStateDecoratedVariable | undefined)) get __backing_stateVar3(): (IStateDecoratedVariable | undefined) + set __options_has_stateVar3(__options_has_stateVar3: (boolean | undefined)) + + get __options_has_stateVar3(): (boolean | undefined) set stateVar4(stateVar4: (Set | undefined)) get stateVar4(): (Set | undefined) set __backing_stateVar4(__backing_stateVar4: (IStateDecoratedVariable> | undefined)) get __backing_stateVar4(): (IStateDecoratedVariable> | undefined) + set __options_has_stateVar4(__options_has_stateVar4: (boolean | undefined)) + + get __options_has_stateVar4(): (boolean | undefined) set stateVar5(stateVar5: (Array | undefined)) get stateVar5(): (Array | undefined) set __backing_stateVar5(__backing_stateVar5: (IStateDecoratedVariable> | undefined)) get __backing_stateVar5(): (IStateDecoratedVariable> | undefined) + set __options_has_stateVar5(__options_has_stateVar5: (boolean | undefined)) + + get __options_has_stateVar5(): (boolean | undefined) set stateVar6(stateVar6: (Array | undefined)) get stateVar6(): (Array | undefined) set __backing_stateVar6(__backing_stateVar6: (IStateDecoratedVariable> | undefined)) get __backing_stateVar6(): (IStateDecoratedVariable> | undefined) + set __options_has_stateVar6(__options_has_stateVar6: (boolean | undefined)) + + get __options_has_stateVar6(): (boolean | undefined) set stateVar7(stateVar7: (Array | undefined)) get stateVar7(): (Array | undefined) set __backing_stateVar7(__backing_stateVar7: (IStateDecoratedVariable> | undefined)) get __backing_stateVar7(): (IStateDecoratedVariable> | undefined) + set __options_has_stateVar7(__options_has_stateVar7: (boolean | undefined)) + + get __options_has_stateVar7(): (boolean | undefined) set stateVar8(stateVar8: (((sr: string)=> void) | undefined)) get stateVar8(): (((sr: string)=> void) | undefined) set __backing_stateVar8(__backing_stateVar8: (IStateDecoratedVariable<((sr: string)=> void)> | undefined)) get __backing_stateVar8(): (IStateDecoratedVariable<((sr: string)=> void)> | undefined) + set __options_has_stateVar8(__options_has_stateVar8: (boolean | undefined)) + + get __options_has_stateVar8(): (boolean | undefined) set stateVar9(stateVar9: (Date | undefined)) get stateVar9(): (Date | undefined) set __backing_stateVar9(__backing_stateVar9: (IStateDecoratedVariable | undefined)) get __backing_stateVar9(): (IStateDecoratedVariable | undefined) + set __options_has_stateVar9(__options_has_stateVar9: (boolean | undefined)) + + get __options_has_stateVar9(): (boolean | undefined) set stateVar10(stateVar10: (Map | undefined)) get stateVar10(): (Map | undefined) set __backing_stateVar10(__backing_stateVar10: (IStateDecoratedVariable> | undefined)) get __backing_stateVar10(): (IStateDecoratedVariable> | undefined) + set __options_has_stateVar10(__options_has_stateVar10: (boolean | undefined)) + + get __options_has_stateVar10(): (boolean | undefined) set stateVar11(stateVar11: ((string | number) | undefined)) get stateVar11(): ((string | number) | undefined) set __backing_stateVar11(__backing_stateVar11: (IStateDecoratedVariable<(string | number)> | undefined)) get __backing_stateVar11(): (IStateDecoratedVariable<(string | number)> | undefined) + set __options_has_stateVar11(__options_has_stateVar11: (boolean | undefined)) + + get __options_has_stateVar11(): (boolean | undefined) set stateVar12(stateVar12: ((Set | Per) | undefined)) get stateVar12(): ((Set | Per) | undefined) set __backing_stateVar12(__backing_stateVar12: (IStateDecoratedVariable<(Set | Per)> | undefined)) get __backing_stateVar12(): (IStateDecoratedVariable<(Set | Per)> | undefined) + set __options_has_stateVar12(__options_has_stateVar12: (boolean | undefined)) + + get __options_has_stateVar12(): (boolean | undefined) } - `; function testParsedAndCheckedTransformer(this: PluginTestContext): void { diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/state/state-to-state.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/state/state-to-state.test.ts index 45f033642e618ebaa5f139698b9bc9b9f55473f5..c1c6c4bef354411c8e92cf8a8906c8605e09cc4f 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/state/state-to-state.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/state/state-to-state.test.ts @@ -54,8 +54,6 @@ import { State as State } from "@ohos.arkui.stateManagement"; function main() {} - - class Per { public str: string; @@ -89,6 +87,7 @@ class Per { return new Child(); }), { childVar1: this.parentVar1, + __options_has_childVar1: true, }, undefined, undefined); })); } @@ -130,6 +129,9 @@ class Per { set __backing_parentVar1(__backing_parentVar1: (IStateDecoratedVariable | undefined)) get __backing_parentVar1(): (IStateDecoratedVariable | undefined) + set __options_has_parentVar1(__options_has_parentVar1: (boolean | undefined)) + + get __options_has_parentVar1(): (boolean | undefined) } @@ -140,6 +142,9 @@ class Per { set __backing_childVar1(__backing_childVar1: (IStateDecoratedVariable | undefined)) get __backing_childVar1(): (IStateDecoratedVariable | undefined) + set __options_has_childVar1(__options_has_childVar1: (boolean | undefined)) + + get __options_has_childVar1(): (boolean | undefined) } `; diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/storagelink/storagelink-appstorage.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/storagelink/storagelink-appstorage.test.ts index 42f22ac6e680a5a0daa68af6cbddaae223bcf8fb..8ab1f52490cee5ff7f7c80c30658cb1eb2712313 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/storagelink/storagelink-appstorage.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/storagelink/storagelink-appstorage.test.ts @@ -125,12 +125,18 @@ class Data { set __backing_storageLink(__backing_storageLink: (IStorageLinkDecoratedVariable | undefined)) get __backing_storageLink(): (IStorageLinkDecoratedVariable | undefined) + set __options_has_storageLink(__options_has_storageLink: (boolean | undefined)) + + get __options_has_storageLink(): (boolean | undefined) set storageLinkObject(storageLinkObject: (Data | undefined)) get storageLinkObject(): (Data | undefined) set __backing_storageLinkObject(__backing_storageLinkObject: (IStorageLinkDecoratedVariable | undefined)) get __backing_storageLinkObject(): (IStorageLinkDecoratedVariable | undefined) + set __options_has_storageLinkObject(__options_has_storageLinkObject: (boolean | undefined)) + + get __options_has_storageLinkObject(): (boolean | undefined) } diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/storagelink/storagelink-complex-type.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/storagelink/storagelink-complex-type.test.ts index f28433b8f357d47610992cb6d8b27c91f917febd..07cf51d725af4167b9c89657c1feaf4f788f04c8 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/storagelink/storagelink-complex-type.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/storagelink/storagelink-complex-type.test.ts @@ -229,42 +229,63 @@ final class Status extends BaseEnum { set __backing_arrayA(__backing_arrayA: (IStorageLinkDecoratedVariable> | undefined)) get __backing_arrayA(): (IStorageLinkDecoratedVariable> | undefined) + set __options_has_arrayA(__options_has_arrayA: (boolean | undefined)) + + get __options_has_arrayA(): (boolean | undefined) set objectA(objectA: (Object | undefined)) get objectA(): (Object | undefined) set __backing_objectA(__backing_objectA: (IStorageLinkDecoratedVariable | undefined)) get __backing_objectA(): (IStorageLinkDecoratedVariable | undefined) + set __options_has_objectA(__options_has_objectA: (boolean | undefined)) + + get __options_has_objectA(): (boolean | undefined) set dateA(dateA: (Date | undefined)) get dateA(): (Date | undefined) set __backing_dateA(__backing_dateA: (IStorageLinkDecoratedVariable | undefined)) get __backing_dateA(): (IStorageLinkDecoratedVariable | undefined) + set __options_has_dateA(__options_has_dateA: (boolean | undefined)) + + get __options_has_dateA(): (boolean | undefined) set setA(setA: (Set | undefined)) get setA(): (Set | undefined) set __backing_setA(__backing_setA: (IStorageLinkDecoratedVariable> | undefined)) get __backing_setA(): (IStorageLinkDecoratedVariable> | undefined) + set __options_has_setA(__options_has_setA: (boolean | undefined)) + + get __options_has_setA(): (boolean | undefined) set mapA(mapA: (Map | undefined)) get mapA(): (Map | undefined) set __backing_mapA(__backing_mapA: (IStorageLinkDecoratedVariable> | undefined)) get __backing_mapA(): (IStorageLinkDecoratedVariable> | undefined) + set __options_has_mapA(__options_has_mapA: (boolean | undefined)) + + get __options_has_mapA(): (boolean | undefined) set classA(classA: (Person | undefined)) get classA(): (Person | undefined) set __backing_classA(__backing_classA: (IStorageLinkDecoratedVariable | undefined)) get __backing_classA(): (IStorageLinkDecoratedVariable | undefined) + set __options_has_classA(__options_has_classA: (boolean | undefined)) + + get __options_has_classA(): (boolean | undefined) set enumA(enumA: (Status | undefined)) get enumA(): (Status | undefined) set __backing_enumA(__backing_enumA: (IStorageLinkDecoratedVariable | undefined)) get __backing_enumA(): (IStorageLinkDecoratedVariable | undefined) + set __options_has_enumA(__options_has_enumA: (boolean | undefined)) + + get __options_has_enumA(): (boolean | undefined) } diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/storagelink/storagelink-primitive-type.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/storagelink/storagelink-primitive-type.test.ts index 923664b6c5c56e850494f828a1d110d0a2b3b28d..439ff46b7210bdf5fb9ff7aceab65527322987cc 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/storagelink/storagelink-primitive-type.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/storagelink/storagelink-primitive-type.test.ts @@ -110,18 +110,27 @@ __EntryWrapper.RegisterNamedRouter("", new __EntryWrapper(), ({ set __backing_numA(__backing_numA: (IStorageLinkDecoratedVariable | undefined)) get __backing_numA(): (IStorageLinkDecoratedVariable | undefined) + set __options_has_numA(__options_has_numA: (boolean | undefined)) + + get __options_has_numA(): (boolean | undefined) set stringA(stringA: (string | undefined)) get stringA(): (string | undefined) set __backing_stringA(__backing_stringA: (IStorageLinkDecoratedVariable | undefined)) get __backing_stringA(): (IStorageLinkDecoratedVariable | undefined) + set __options_has_stringA(__options_has_stringA: (boolean | undefined)) + + get __options_has_stringA(): (boolean | undefined) set booleanA(booleanA: (boolean | undefined)) get booleanA(): (boolean | undefined) set __backing_booleanA(__backing_booleanA: (IStorageLinkDecoratedVariable | undefined)) get __backing_booleanA(): (IStorageLinkDecoratedVariable | undefined) + set __options_has_booleanA(__options_has_booleanA: (boolean | undefined)) + + get __options_has_booleanA(): (boolean | undefined) } diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/storageprop-ref/storageprop-ref-complex-type.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/storageprop-ref/storageprop-ref-complex-type.test.ts index c38a8280e284b45c1a66b934c21dab16ce6b7f82..3ecdc503099575b4075d47072aa8d3d0687a11f8 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/storageprop-ref/storageprop-ref-complex-type.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/storageprop-ref/storageprop-ref-complex-type.test.ts @@ -52,8 +52,6 @@ import { StoragePropRef as StoragePropRef } from "@ohos.arkui.stateManagement"; function main() {} - - class Person { public name: string = ""; @@ -225,42 +223,63 @@ final class Status extends BaseEnum { set __backing_arrayB(__backing_arrayB: (IStoragePropRefDecoratedVariable> | undefined)) get __backing_arrayB(): (IStoragePropRefDecoratedVariable> | undefined) + set __options_has_arrayB(__options_has_arrayB: (boolean | undefined)) + + get __options_has_arrayB(): (boolean | undefined) set objectB(objectB: (Object | undefined)) get objectB(): (Object | undefined) set __backing_objectB(__backing_objectB: (IStoragePropRefDecoratedVariable | undefined)) get __backing_objectB(): (IStoragePropRefDecoratedVariable | undefined) + set __options_has_objectB(__options_has_objectB: (boolean | undefined)) + + get __options_has_objectB(): (boolean | undefined) set dateB(dateB: (Date | undefined)) get dateB(): (Date | undefined) set __backing_dateB(__backing_dateB: (IStoragePropRefDecoratedVariable | undefined)) get __backing_dateB(): (IStoragePropRefDecoratedVariable | undefined) + set __options_has_dateB(__options_has_dateB: (boolean | undefined)) + + get __options_has_dateB(): (boolean | undefined) set setB(setB: (Set | undefined)) get setB(): (Set | undefined) set __backing_setB(__backing_setB: (IStoragePropRefDecoratedVariable> | undefined)) get __backing_setB(): (IStoragePropRefDecoratedVariable> | undefined) + set __options_has_setB(__options_has_setB: (boolean | undefined)) + + get __options_has_setB(): (boolean | undefined) set mapB(mapB: (Map | undefined)) get mapB(): (Map | undefined) set __backing_mapB(__backing_mapB: (IStoragePropRefDecoratedVariable> | undefined)) get __backing_mapB(): (IStoragePropRefDecoratedVariable> | undefined) + set __options_has_mapB(__options_has_mapB: (boolean | undefined)) + + get __options_has_mapB(): (boolean | undefined) set classB(classB: (Person | undefined)) get classB(): (Person | undefined) set __backing_classB(__backing_classB: (IStoragePropRefDecoratedVariable | undefined)) get __backing_classB(): (IStoragePropRefDecoratedVariable | undefined) + set __options_has_classB(__options_has_classB: (boolean | undefined)) + + get __options_has_classB(): (boolean | undefined) set enumB(enumB: (Status | undefined)) get enumB(): (Status | undefined) set __backing_enumB(__backing_enumB: (IStoragePropRefDecoratedVariable | undefined)) get __backing_enumB(): (IStoragePropRefDecoratedVariable | undefined) + set __options_has_enumB(__options_has_enumB: (boolean | undefined)) + + get __options_has_enumB(): (boolean | undefined) } `; diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/storageprop-ref/storageprop-ref-primitive-type.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/storageprop-ref/storageprop-ref-primitive-type.test.ts index 31d27dd460e696ad5a4a97493c5ff99676f0280a..22719b1f62d7dcb5a2ecdb2ee43495dc755b40e6 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/storageprop-ref/storageprop-ref-primitive-type.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/storageprop-ref/storageprop-ref-primitive-type.test.ts @@ -52,8 +52,6 @@ import { StoragePropRef as StoragePropRef } from "@ohos.arkui.stateManagement"; function main() {} - - @Component() final struct MyStateSample extends CustomComponent { public __initializeStruct(initializers: (__Options_MyStateSample | undefined), @memo() content: ((()=> void) | undefined)): void { this.__backing_numB = STATE_MGMT_FACTORY.makeStoragePropRef(this, "Prop1", "numB", 43) @@ -128,30 +126,45 @@ function main() {} set __backing_numB(__backing_numB: (IStoragePropRefDecoratedVariable | undefined)) get __backing_numB(): (IStoragePropRefDecoratedVariable | undefined) + set __options_has_numB(__options_has_numB: (boolean | undefined)) + + get __options_has_numB(): (boolean | undefined) set stringB(stringB: (string | undefined)) get stringB(): (string | undefined) set __backing_stringB(__backing_stringB: (IStoragePropRefDecoratedVariable | undefined)) get __backing_stringB(): (IStoragePropRefDecoratedVariable | undefined) + set __options_has_stringB(__options_has_stringB: (boolean | undefined)) + + get __options_has_stringB(): (boolean | undefined) set booleanB(booleanB: (boolean | undefined)) get booleanB(): (boolean | undefined) set __backing_booleanB(__backing_booleanB: (IStoragePropRefDecoratedVariable | undefined)) get __backing_booleanB(): (IStoragePropRefDecoratedVariable | undefined) + set __options_has_booleanB(__options_has_booleanB: (boolean | undefined)) + + get __options_has_booleanB(): (boolean | undefined) set undefinedB(undefinedB: (undefined | undefined)) get undefinedB(): (undefined | undefined) set __backing_undefinedB(__backing_undefinedB: (IStoragePropRefDecoratedVariable | undefined)) get __backing_undefinedB(): (IStoragePropRefDecoratedVariable | undefined) + set __options_has_undefinedB(__options_has_undefinedB: (boolean | undefined)) + + get __options_has_undefinedB(): (boolean | undefined) set nullB(nullB: (null | undefined)) get nullB(): (null | undefined) set __backing_nullB(__backing_nullB: (IStoragePropRefDecoratedVariable | undefined)) get __backing_nullB(): (IStoragePropRefDecoratedVariable | undefined) + set __options_has_nullB(__options_has_nullB: (boolean | undefined)) + + get __options_has_nullB(): (boolean | undefined) } `; diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/storageprop/storageprop-appstorage.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/storageprop/storageprop-appstorage.test.ts deleted file mode 100644 index 374e2187be4c66fdb21e1694899248389bafd1a1..0000000000000000000000000000000000000000 --- a/arkui-plugins/test/ut/ui-plugins/decorators/storageprop/storageprop-appstorage.test.ts +++ /dev/null @@ -1,174 +0,0 @@ -/* - * 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 * as path from 'path'; -import { PluginTester } from '../../../../utils/plugin-tester'; -import { mockBuildConfig } from '../../../../utils/artkts-config'; -import { getRootPath, MOCK_ENTRY_DIR_PATH } from '../../../../utils/path-config'; -import { parseDumpSrc } from '../../../../utils/parse-string'; -import { uiNoRecheck, recheck } from '../../../../utils/plugins'; -import { BuildConfig, PluginTestContext } from '../../../../utils/shared-types'; -import { uiTransform } from '../../../../../ui-plugins'; -import { Plugins } from '../../../../../common/plugin-context'; - -const STORAGEPROP_DIR_PATH: string = 'decorators/storageprop'; - -const buildConfig: BuildConfig = mockBuildConfig(); -buildConfig.compileFiles = [ - path.resolve(getRootPath(), MOCK_ENTRY_DIR_PATH, STORAGEPROP_DIR_PATH, 'storageprop-appstorage.ets'), -]; - -const storagePropTransform: Plugins = { - name: 'storageprop', - parsed: uiTransform().parsed, -} - -const pluginTester = new PluginTester('test storageprop with appstorage', buildConfig); - -const expectedScript: string = ` -import { STATE_MGMT_FACTORY as STATE_MGMT_FACTORY } from "arkui.stateManagement.decorator"; - -import { IStoragePropRefDecoratedVariable as IStoragePropRefDecoratedVariable } from "arkui.stateManagement.decorator"; - -import { memo as memo } from "arkui.stateManagement.runtime"; - -import { TextAttribute as TextAttribute } from "arkui.component.text"; - -import { NavInterface as NavInterface } from "arkui.UserView"; - -import { PageLifeCycle as PageLifeCycle } from "arkui.component.customComponent"; - -import { EntryPoint as EntryPoint } from "arkui.UserView"; - - -import { CustomComponent as CustomComponent } from "arkui.component.customComponent"; - -import { Component as Component, Entry as Entry, Column as Column, Text as Text, ClickEvent as ClickEvent } from "@ohos.arkui.component"; - -import { StorageProp as StorageProp, AppStorage as AppStorage } from "@ohos.arkui.stateManagement"; - -function main() {} - -AppStorage.setOrCreate("PropA", 47); -AppStorage.setOrCreate("PropB", new Data(50)); - -__EntryWrapper.RegisterNamedRouter("", new __EntryWrapper(), ({ - bundleName: "com.example.mock", - moduleName: "entry", - pagePath: "../../../decorators/storageprop/storageprop-appstorage", - pageFullPath: "test/demo/mock/decorators/storageprop/storageprop-appstorage", - integratedHsp: "false", - } as NavInterface)); - -class Data { - public code: number; - - public constructor(code: number) { - this.code = code; - } - -} - -@Entry({useSharedStorage:false,storage:"",routeName:""}) @Component() final struct Index extends CustomComponent implements PageLifeCycle { - public __initializeStruct(initializers: (__Options_Index | undefined), @memo() content: ((()=> void) | undefined)): void { - this.__backing_storageProp = STATE_MGMT_FACTORY.makeStoragePropRef(this, "PropA", "storageProp", 1) - this.__backing_storagePropObject = STATE_MGMT_FACTORY.makeStoragePropRef(this, "PropB", "storagePropObject", new Data(1)) - } - - public __updateStruct(initializers: (__Options_Index | undefined)): void {} - - private __backing_storageProp?: IStoragePropRefDecoratedVariable; - - public get storageProp(): number { - return this.__backing_storageProp!.get(); - } - - public set storageProp(value: number) { - this.__backing_storageProp!.set(value); - } - - private __backing_storagePropObject?: IStoragePropRefDecoratedVariable; - - public get storagePropObject(): Data { - return this.__backing_storagePropObject!.get(); - } - - public set storagePropObject(value: Data) { - this.__backing_storagePropObject!.set(value); - } - - @memo() public build() { - Column(undefined, undefined, @memo() (() => { - Text(@memo() ((instance: TextAttribute): void => { - instance.onClick(((e: ClickEvent) => { - this.storageProp += 1; - })); - return; - }), \`From AppStorage \${this.storageProp}\`, undefined, undefined); - Text(@memo() ((instance: TextAttribute): void => { - instance.onClick(((e: ClickEvent) => { - this.storagePropObject.code += 1; - })); - return; - }), \`From AppStorage \${this.storagePropObject.code}\`, undefined, undefined); - })); - } - - public constructor() {} - -} - -@Entry({useSharedStorage:false,storage:"",routeName:""}) @Component() export interface __Options_Index { - set storageProp(storageProp: (number | undefined)) - - get storageProp(): (number | undefined) - set __backing_storageProp(__backing_storageProp: (IStoragePropRefDecoratedVariable | undefined)) - - get __backing_storageProp(): (IStoragePropRefDecoratedVariable | undefined) - set storagePropObject(storagePropObject: (Data | undefined)) - - get storagePropObject(): (Data | undefined) - set __backing_storagePropObject(__backing_storagePropObject: (IStoragePropRefDecoratedVariable | undefined)) - - get __backing_storagePropObject(): (IStoragePropRefDecoratedVariable | undefined) - -} - -class __EntryWrapper extends EntryPoint { - @memo() public entry(): void { - Index._instantiateImpl(undefined, (() => { - return new Index(); - }), undefined, undefined, undefined); - } - - public constructor() {} - -} -`; - -function testStoragePropTransformer(this: PluginTestContext): void { - expect(parseDumpSrc(this.scriptSnapshot ?? '')).toBe(parseDumpSrc(expectedScript)); -} - -pluginTester.run( - 'test storageprop with appstorage', - [storagePropTransform, uiNoRecheck, recheck], - { - 'checked:ui-no-recheck': [testStoragePropTransformer], - }, - { - stopAfter: 'checked', - } -); diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/storageprop/storageprop-complex-type.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/storageprop/storageprop-complex-type.test.ts deleted file mode 100644 index 65aea99c9f412cc1e5eaf02e11704cacf08b8ae6..0000000000000000000000000000000000000000 --- a/arkui-plugins/test/ut/ui-plugins/decorators/storageprop/storageprop-complex-type.test.ts +++ /dev/null @@ -1,296 +0,0 @@ -/* - * 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 * as path from 'path'; -import { PluginTester } from '../../../../utils/plugin-tester'; -import { mockBuildConfig } from '../../../../utils/artkts-config'; -import { getRootPath, MOCK_ENTRY_DIR_PATH } from '../../../../utils/path-config'; -import { parseDumpSrc } from '../../../../utils/parse-string'; -import { uiNoRecheck, recheck } from '../../../../utils/plugins'; -import { BuildConfig, PluginTestContext } from '../../../../utils/shared-types'; -import { uiTransform } from '../../../../../ui-plugins'; -import { Plugins } from '../../../../../common/plugin-context'; - -const STORAGEPROP_DIR_PATH: string = 'decorators/storageprop'; - -const buildConfig: BuildConfig = mockBuildConfig(); -buildConfig.compileFiles = [ - path.resolve(getRootPath(), MOCK_ENTRY_DIR_PATH, STORAGEPROP_DIR_PATH, 'storageprop-complex-type.ets'), -]; - -const storagePropTransform: Plugins = { - name: 'storageprop', - parsed: uiTransform().parsed, -} - -const pluginTester = new PluginTester('test storageprop complex type transform', buildConfig); - -const expectedScript: string = ` -import { memo as memo } from "arkui.stateManagement.runtime"; -import { STATE_MGMT_FACTORY as STATE_MGMT_FACTORY } from "arkui.stateManagement.decorator"; -import { IStoragePropRefDecoratedVariable as IStoragePropRefDecoratedVariable } from "arkui.stateManagement.decorator"; -import { NavInterface as NavInterface } from "arkui.UserView"; -import { PageLifeCycle as PageLifeCycle } from "arkui.component.customComponent"; -import { EntryPoint as EntryPoint } from "arkui.UserView"; -import { CustomComponent as CustomComponent } from "arkui.component.customComponent"; -import { Component as Component, Entry as Entry } from "@ohos.arkui.component"; -import { StorageProp as StorageProp } from "@ohos.arkui.stateManagement"; - -function main() {} - -__EntryWrapper.RegisterNamedRouter("", new __EntryWrapper(), ({ - bundleName: "com.example.mock", - moduleName: "entry", - pagePath: "../../../decorators/storageprop/storageprop-complex-type", - pageFullPath: "test/demo/mock/decorators/storageprop/storageprop-complex-type", - integratedHsp: "false", - } as NavInterface)); - -class Person { - public name: string = ""; - - public constructor(name: string) {} - -} - -final class Status extends BaseEnum { - private readonly #ordinal: int; - - private static () {} - - public constructor(ordinal: int, value: int) { - super(value); - this.#ordinal = ordinal; - } - - public static readonly Success: Status = new Status(0, 200); - - public static readonly NotFound: Status = new Status(1, 404); - - public static readonly ServerError: Status = new Status(2, 500); - - private static readonly #NamesArray: String[] = ["Success", "NotFound", "ServerError"]; - - private static readonly #ValuesArray: int[] = [200, 404, 500]; - - private static readonly #StringValuesArray: String[] = ["200", "404", "500"]; - - private static readonly #ItemsArray: Status[] = [Status.Success, Status.NotFound, Status.ServerError]; - - public getName(): String { - return Status.#NamesArray[this.#ordinal]; - } - - public static getValueOf(name: String): Status { - for (let i = 0;((i) < (Status.#NamesArray.length));(++i)) { - if (((name) == (Status.#NamesArray[i]))) { - return Status.#ItemsArray[i]; - } - } - throw new Error((("No enum constant Status.") + (name))); - } - - public static fromValue(value: int): Status { - for (let i = 0;((i) < (Status.#ValuesArray.length));(++i)) { - if (((value) == (Status.#ValuesArray[i]))) { - return Status.#ItemsArray[i]; - } - } - throw new Error((("No enum Status with value ") + (value))); - } - - public valueOf(): int { - return Status.#ValuesArray[this.#ordinal]; - } - - public toString(): String { - return Status.#StringValuesArray[this.#ordinal]; - } - - public static values(): Status[] { - return Status.#ItemsArray; - } - - public getOrdinal(): int { - return this.#ordinal; - } - - public static $_get(e: Status): String { - return e.getName(); - } - -} - -@Entry({useSharedStorage:false,storage:"",routeName:""}) @Component() final struct MyStateSample extends CustomComponent implements PageLifeCycle { - public __initializeStruct(initializers: (__Options_MyStateSample | undefined), @memo() content: ((()=> void) | undefined)): void { - this.__backing_arrayB = STATE_MGMT_FACTORY.makeStoragePropRef>(this, "Prop1", "arrayB", [1, 2, 3]) - this.__backing_objectB = STATE_MGMT_FACTORY.makeStoragePropRef(this, "Prop2", "objectB", {}) - this.__backing_dateB = STATE_MGMT_FACTORY.makeStoragePropRef(this, "Prop3", "dateB", new Date("2021-09-09")) - this.__backing_setB = STATE_MGMT_FACTORY.makeStoragePropRef>(this, "Prop4", "setB", new Set()) - this.__backing_mapB = STATE_MGMT_FACTORY.makeStoragePropRef>(this, "Prop5", "mapB", new Map()) - this.__backing_classB = STATE_MGMT_FACTORY.makeStoragePropRef(this, "Prop7", "classB", new Person("Kevin")) - this.__backing_enumB = STATE_MGMT_FACTORY.makeStoragePropRef(this, "Prop8", "enumB", Status.NotFound) - } - - public __updateStruct(initializers: (__Options_MyStateSample | undefined)): void {} - - private __backing_arrayB?: IStoragePropRefDecoratedVariable>; - - public get arrayB(): Array { - return this.__backing_arrayB!.get(); - } - - public set arrayB(value: Array) { - this.__backing_arrayB!.set(value); - } - - private __backing_objectB?: IStoragePropRefDecoratedVariable; - - public get objectB(): Object { - return this.__backing_objectB!.get(); - } - - public set objectB(value: Object) { - this.__backing_objectB!.set(value); - } - - private __backing_dateB?: IStoragePropRefDecoratedVariable; - - public get dateB(): Date { - return this.__backing_dateB!.get(); - } - - public set dateB(value: Date) { - this.__backing_dateB!.set(value); - } - - private __backing_setB?: IStoragePropRefDecoratedVariable>; - - public get setB(): Set { - return this.__backing_setB!.get(); - } - - public set setB(value: Set) { - this.__backing_setB!.set(value); - } - - private __backing_mapB?: IStoragePropRefDecoratedVariable>; - - public get mapB(): Map { - return this.__backing_mapB!.get(); - } - - public set mapB(value: Map) { - this.__backing_mapB!.set(value); - } - - private __backing_classB?: IStoragePropRefDecoratedVariable; - - public get classB(): Person { - return this.__backing_classB!.get(); - } - - public set classB(value: Person) { - this.__backing_classB!.set(value); - } - - private __backing_enumB?: IStoragePropRefDecoratedVariable; - - public get enumB(): Status { - return this.__backing_enumB!.get(); - } - - public set enumB(value: Status) { - this.__backing_enumB!.set(value); - } - - @memo() public build() {} - - public constructor() {} - -} - -@Entry({useSharedStorage:false,storage:"",routeName:""}) @Component() export interface __Options_MyStateSample { - set arrayB(arrayB: (Array | undefined)) - - get arrayB(): (Array | undefined) - set __backing_arrayB(__backing_arrayB: (IStoragePropRefDecoratedVariable> | undefined)) - - get __backing_arrayB(): (IStoragePropRefDecoratedVariable> | undefined) - set objectB(objectB: (Object | undefined)) - - get objectB(): (Object | undefined) - set __backing_objectB(__backing_objectB: (IStoragePropRefDecoratedVariable | undefined)) - - get __backing_objectB(): (IStoragePropRefDecoratedVariable | undefined) - set dateB(dateB: (Date | undefined)) - - get dateB(): (Date | undefined) - set __backing_dateB(__backing_dateB: (IStoragePropRefDecoratedVariable | undefined)) - - get __backing_dateB(): (IStoragePropRefDecoratedVariable | undefined) - set setB(setB: (Set | undefined)) - - get setB(): (Set | undefined) - set __backing_setB(__backing_setB: (IStoragePropRefDecoratedVariable> | undefined)) - - get __backing_setB(): (IStoragePropRefDecoratedVariable> | undefined) - set mapB(mapB: (Map | undefined)) - - get mapB(): (Map | undefined) - set __backing_mapB(__backing_mapB: (IStoragePropRefDecoratedVariable> | undefined)) - - get __backing_mapB(): (IStoragePropRefDecoratedVariable> | undefined) - set classB(classB: (Person | undefined)) - - get classB(): (Person | undefined) - set __backing_classB(__backing_classB: (IStoragePropRefDecoratedVariable | undefined)) - - get __backing_classB(): (IStoragePropRefDecoratedVariable | undefined) - set enumB(enumB: (Status | undefined)) - - get enumB(): (Status | undefined) - set __backing_enumB(__backing_enumB: (IStoragePropRefDecoratedVariable | undefined)) - - get __backing_enumB(): (IStoragePropRefDecoratedVariable | undefined) - -} - -class __EntryWrapper extends EntryPoint { - @memo() public entry(): void { - MyStateSample._instantiateImpl(undefined, (() => { - return new MyStateSample(); - }), undefined, undefined, undefined); - } - - public constructor() {} - -} -`; - -function testStoragePropTransformer(this: PluginTestContext): void { - expect(parseDumpSrc(this.scriptSnapshot ?? '')).toBe(parseDumpSrc(expectedScript)); -} - -pluginTester.run( - 'test storageprop complex type transform', - [storagePropTransform, uiNoRecheck, recheck], - { - 'checked:ui-no-recheck': [testStoragePropTransformer], - }, - { - stopAfter: 'checked', - } -); diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/storageprop/storageprop-primitive-type.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/storageprop/storageprop-primitive-type.test.ts deleted file mode 100644 index 660a51361e77b1c811511ebda2b255bc1a66e897..0000000000000000000000000000000000000000 --- a/arkui-plugins/test/ut/ui-plugins/decorators/storageprop/storageprop-primitive-type.test.ts +++ /dev/null @@ -1,162 +0,0 @@ -/* - * 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 * as path from 'path'; -import { PluginTester } from '../../../../utils/plugin-tester'; -import { mockBuildConfig } from '../../../../utils/artkts-config'; -import { getRootPath, MOCK_ENTRY_DIR_PATH } from '../../../../utils/path-config'; -import { parseDumpSrc } from '../../../../utils/parse-string'; -import { uiNoRecheck, recheck } from '../../../../utils/plugins'; -import { BuildConfig, PluginTestContext } from '../../../../utils/shared-types'; -import { uiTransform } from '../../../../../ui-plugins'; -import { Plugins } from '../../../../../common/plugin-context'; - -const STORAGEPROP_DIR_PATH: string = 'decorators/storageprop'; - -const buildConfig: BuildConfig = mockBuildConfig(); -buildConfig.compileFiles = [ - path.resolve(getRootPath(), MOCK_ENTRY_DIR_PATH, STORAGEPROP_DIR_PATH, 'storageprop-primitive-type.ets'), -]; - -const storagePropTransform: Plugins = { - name: 'storageprop', - parsed: uiTransform().parsed, -} - -const pluginTester = new PluginTester('test storageprop primitive type transform', buildConfig); - -const expectedScript: string = ` -import { memo as memo } from "arkui.stateManagement.runtime"; - -import { STATE_MGMT_FACTORY as STATE_MGMT_FACTORY } from "arkui.stateManagement.decorator"; - -import { IStoragePropRefDecoratedVariable as IStoragePropRefDecoratedVariable } from "arkui.stateManagement.decorator"; - -import { NavInterface as NavInterface } from "arkui.UserView"; - -import { PageLifeCycle as PageLifeCycle } from "arkui.component.customComponent"; - -import { EntryPoint as EntryPoint } from "arkui.UserView"; - - -import { CustomComponent as CustomComponent } from "arkui.component.customComponent"; - -import { Component as Component, Entry as Entry } from "@ohos.arkui.component"; - -import { StorageProp as StorageProp } from "@ohos.arkui.stateManagement"; - -function main() {} - -__EntryWrapper.RegisterNamedRouter("", new __EntryWrapper(), ({ - bundleName: "com.example.mock", - moduleName: "entry", - pagePath: "../../../decorators/storageprop/storageprop-primitive-type", - pageFullPath: "test/demo/mock/decorators/storageprop/storageprop-primitive-type", - integratedHsp: "false", - } as NavInterface)); - -@Entry({useSharedStorage:false,storage:"",routeName:""}) @Component() final struct MyStateSample extends CustomComponent implements PageLifeCycle { - public __initializeStruct(initializers: (__Options_MyStateSample | undefined), @memo() content: ((()=> void) | undefined)): void { - this.__backing_numB = STATE_MGMT_FACTORY.makeStoragePropRef(this, "Prop1", "numB", 43) - this.__backing_stringB = STATE_MGMT_FACTORY.makeStoragePropRef(this, "Prop2", "stringB", "BB") - this.__backing_booleanB = STATE_MGMT_FACTORY.makeStoragePropRef(this, "Prop3", "booleanB", false) - } - - public __updateStruct(initializers: (__Options_MyStateSample | undefined)): void {} - - private __backing_numB?: IStoragePropRefDecoratedVariable; - - public get numB(): number { - return this.__backing_numB!.get(); - } - - public set numB(value: number) { - this.__backing_numB!.set(value); - } - - private __backing_stringB?: IStoragePropRefDecoratedVariable; - - public get stringB(): string { - return this.__backing_stringB!.get(); - } - - public set stringB(value: string) { - this.__backing_stringB!.set(value); - } - - private __backing_booleanB?: IStoragePropRefDecoratedVariable; - - public get booleanB(): boolean { - return this.__backing_booleanB!.get(); - } - - public set booleanB(value: boolean) { - this.__backing_booleanB!.set(value); - } - - @memo() public build() {} - - public constructor() {} - -} - -@Entry({useSharedStorage:false,storage:"",routeName:""}) @Component() export interface __Options_MyStateSample { - set numB(numB: (number | undefined)) - - get numB(): (number | undefined) - set __backing_numB(__backing_numB: (IStoragePropRefDecoratedVariable | undefined)) - - get __backing_numB(): (IStoragePropRefDecoratedVariable | undefined) - set stringB(stringB: (string | undefined)) - - get stringB(): (string | undefined) - set __backing_stringB(__backing_stringB: (IStoragePropRefDecoratedVariable | undefined)) - - get __backing_stringB(): (IStoragePropRefDecoratedVariable | undefined) - set booleanB(booleanB: (boolean | undefined)) - - get booleanB(): (boolean | undefined) - set __backing_booleanB(__backing_booleanB: (IStoragePropRefDecoratedVariable | undefined)) - - get __backing_booleanB(): (IStoragePropRefDecoratedVariable | undefined) - -} - -class __EntryWrapper extends EntryPoint { - @memo() public entry(): void { - MyStateSample._instantiateImpl(undefined, (() => { - return new MyStateSample(); - }), undefined, undefined, undefined); - } - - public constructor() {} - -} -`; - -function testStoragePropTransformer(this: PluginTestContext): void { - expect(parseDumpSrc(this.scriptSnapshot ?? '')).toBe(parseDumpSrc(expectedScript)); -} - -pluginTester.run( - 'test storageprop primitive type transform', - [storagePropTransform, uiNoRecheck, recheck], - { - 'checked:ui-no-recheck': [testStoragePropTransformer], - }, - { - stopAfter: 'checked', - } -); diff --git a/arkui-plugins/test/ut/ui-plugins/decorators/watch/watch-basic.test.ts b/arkui-plugins/test/ut/ui-plugins/decorators/watch/watch-basic.test.ts index f38b5f6d65e8686a9fb15aac64cde388132b597d..f63b791643296cf3613c06c6d8f2162164999433 100644 --- a/arkui-plugins/test/ut/ui-plugins/decorators/watch/watch-basic.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/decorators/watch/watch-basic.test.ts @@ -52,7 +52,7 @@ import { LinkSourceType as LinkSourceType } from "arkui.stateManagement.decorato import { ILinkDecoratedVariable as ILinkDecoratedVariable } from "arkui.stateManagement.decorator"; -import { IPropDecoratedVariable as IPropDecoratedVariable } from "arkui.stateManagement.decorator"; +import { IPropRefDecoratedVariable as IPropRefDecoratedVariable } from "arkui.stateManagement.decorator"; import { IStateDecoratedVariable as IStateDecoratedVariable } from "arkui.stateManagement.decorator"; @@ -78,12 +78,11 @@ import { PageLifeCycle as PageLifeCycle } from "arkui.component.customComponent" import { EntryPoint as EntryPoint } from "arkui.UserView"; - import { CustomComponent as CustomComponent } from "arkui.component.customComponent"; import { Component as Component, Entry as Entry, Column as Column } from "@ohos.arkui.component"; -import { State as State, Prop as Prop, StorageLink as StorageLink, StorageProp as StorageProp, Link as Link, Watch as Watch, ObjectLink as ObjectLink, Observed as Observed, Track as Track, Provide as Provide, Consume as Consume } from "@ohos.arkui.stateManagement"; +import { State as State, PropRef as PropRef, StorageLink as StorageLink, StoragePropRef as StoragePropRef, Link as Link, Watch as Watch, ObjectLink as ObjectLink, Observed as Observed, Track as Track, Provide as Provide, Consume as Consume } from "@ohos.arkui.stateManagement"; function main() {} @@ -151,12 +150,12 @@ __EntryWrapper.RegisterNamedRouter("", new __EntryWrapper(), ({ (((gensym___76198660) == (null)) ? undefined : gensym___76198660.statevar)})) ?? ("Hello World")), ((_: string): void => { this.stateOnChange(_); })); - this.__backing_propvar = STATE_MGMT_FACTORY.makeProp(this, "propvar", ((({let gensym___241486692 = initializers; + this.__backing_propvar = STATE_MGMT_FACTORY.makePropRef(this, "propvar", ((({let gensym___241486692 = initializers; (((gensym___241486692) == (null)) ? undefined : gensym___241486692.propvar)})) ?? ("Hello World")), ((_: string): void => { this.propOnChange(_); })); if (({let gensym___165820150 = initializers; - (((gensym___165820150) == (null)) ? undefined : gensym___165820150.__backing_linkvar)})) { + (((gensym___165820150) == (null)) ? undefined : gensym___165820150.__options_has_linkvar)})) { this.__backing_linkvar = STATE_MGMT_FACTORY.makeLink(this, "linkvar", initializers!.__backing_linkvar!, ((_: string): void => { this.linkOnChange(_); })); @@ -178,13 +177,13 @@ __EntryWrapper.RegisterNamedRouter("", new __EntryWrapper(), ({ } public __updateStruct(initializers: (__Options_MyStateSample | undefined)): void { - if (((({let gensym___220608839 = initializers; - (((gensym___220608839) == (null)) ? undefined : gensym___220608839.propvar)})) !== (undefined))) { + if (({let gensym___122439192 = initializers; + (((gensym___122439192) == (null)) ? undefined : gensym___122439192.__options_has_propvar)})) { this.__backing_propvar!.update((initializers!.propvar as string)); } - if (((({let gensym___164966179 = initializers; - (((gensym___164966179) == (null)) ? undefined : gensym___164966179.objectlinkvar)})) !== (undefined))) { - this.__backing_objectlinkvar!.update(initializers!.objectlinkvar!); + if (({let gensym___94896492 = initializers; + (((gensym___94896492) == (null)) ? undefined : gensym___94896492.__options_has_objectlinkvar)})) { + this.__backing_objectlinkvar!.update((initializers!.objectlinkvar as A)); } } @@ -198,7 +197,7 @@ __EntryWrapper.RegisterNamedRouter("", new __EntryWrapper(), ({ this.__backing_statevar!.set(value); } - private __backing_propvar?: IPropDecoratedVariable; + private __backing_propvar?: IPropRefDecoratedVariable; public get propvar(): string { return this.__backing_propvar!.get(); @@ -316,42 +315,63 @@ __EntryWrapper.RegisterNamedRouter("", new __EntryWrapper(), ({ @Watch({value:"stateOnChange"}) set __backing_statevar(__backing_statevar: (IStateDecoratedVariable | undefined)) @Watch({value:"stateOnChange"}) get __backing_statevar(): (IStateDecoratedVariable | undefined) + set __options_has_statevar(__options_has_statevar: (boolean | undefined)) + + get __options_has_statevar(): (boolean | undefined) set propvar(propvar: (string | undefined)) get propvar(): (string | undefined) - @Watch({value:"propOnChange"}) set __backing_propvar(__backing_propvar: (IPropDecoratedVariable | undefined)) + @Watch({value:"propOnChange"}) set __backing_propvar(__backing_propvar: (IPropRefDecoratedVariable | undefined)) + + @Watch({value:"propOnChange"}) get __backing_propvar(): (IPropRefDecoratedVariable | undefined) + set __options_has_propvar(__options_has_propvar: (boolean | undefined)) - @Watch({value:"propOnChange"}) get __backing_propvar(): (IPropDecoratedVariable | undefined) + get __options_has_propvar(): (boolean | undefined) @__Link_intrinsic() set linkvar(linkvar: (string | undefined)) @__Link_intrinsic() get linkvar(): (string | undefined) @Watch({value:"linkOnChange"}) set __backing_linkvar(__backing_linkvar: (LinkSourceType | undefined)) @Watch({value:"linkOnChange"}) get __backing_linkvar(): (LinkSourceType | undefined) + set __options_has_linkvar(__options_has_linkvar: (boolean | undefined)) + + get __options_has_linkvar(): (boolean | undefined) set storagelinkvar(storagelinkvar: (string | undefined)) get storagelinkvar(): (string | undefined) @Watch({value:"storageLinkOnChange"}) set __backing_storagelinkvar(__backing_storagelinkvar: (IStorageLinkDecoratedVariable | undefined)) @Watch({value:"storageLinkOnChange"}) get __backing_storagelinkvar(): (IStorageLinkDecoratedVariable | undefined) + set __options_has_storagelinkvar(__options_has_storagelinkvar: (boolean | undefined)) + + get __options_has_storagelinkvar(): (boolean | undefined) set storagepropvar(storagepropvar: (string | undefined)) get storagepropvar(): (string | undefined) @Watch({value:"storagePropOnChange"}) set __backing_storagepropvar(__backing_storagepropvar: (IStoragePropRefDecoratedVariable | undefined)) @Watch({value:"storagePropOnChange"}) get __backing_storagepropvar(): (IStoragePropRefDecoratedVariable | undefined) + set __options_has_storagepropvar(__options_has_storagepropvar: (boolean | undefined)) + + get __options_has_storagepropvar(): (boolean | undefined) set objectlinkvar(objectlinkvar: (A | undefined)) get objectlinkvar(): (A | undefined) @Watch({value:"objectLinkOnChange"}) set __backing_objectlinkvar(__backing_objectlinkvar: (IObjectLinkDecoratedVariable | undefined)) @Watch({value:"objectLinkOnChange"}) get __backing_objectlinkvar(): (IObjectLinkDecoratedVariable | undefined) + set __options_has_objectlinkvar(__options_has_objectlinkvar: (boolean | undefined)) + + get __options_has_objectlinkvar(): (boolean | undefined) set providevar(providevar: (string | undefined)) get providevar(): (string | undefined) @Watch({value:"ProvideOnChange"}) set __backing_providevar(__backing_providevar: (IProvideDecoratedVariable | undefined)) @Watch({value:"ProvideOnChange"}) get __backing_providevar(): (IProvideDecoratedVariable | undefined) + set __options_has_providevar(__options_has_providevar: (boolean | undefined)) + + get __options_has_providevar(): (boolean | undefined) } @@ -362,6 +382,9 @@ __EntryWrapper.RegisterNamedRouter("", new __EntryWrapper(), ({ @Watch({value:"ConsumeOnChange"}) set __backing_providevar(__backing_providevar: (IConsumeDecoratedVariable | undefined)) @Watch({value:"ConsumeOnChange"}) get __backing_providevar(): (IConsumeDecoratedVariable | undefined) + set __options_has_providevar(__options_has_providevar: (boolean | undefined)) + + get __options_has_providevar(): (boolean | undefined) } diff --git a/arkui-plugins/test/ut/ui-plugins/double-dollar/double-dollar-griditem.test.ts b/arkui-plugins/test/ut/ui-plugins/double-dollar/double-dollar-griditem.test.ts index 570b3cf1af5611e5e1600cef15109170acbc0adb..d8eb114da4da1504eac23d970da954fe077a5454 100644 --- a/arkui-plugins/test/ut/ui-plugins/double-dollar/double-dollar-griditem.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/double-dollar/double-dollar-griditem.test.ts @@ -65,7 +65,6 @@ let c: boolean; function main() {} c = false; - __EntryWrapper.RegisterNamedRouter("", new __EntryWrapper(), ({ bundleName: "com.example.mock", moduleName: "entry", @@ -132,6 +131,9 @@ __EntryWrapper.RegisterNamedRouter("", new __EntryWrapper(), ({ set __backing_boo(__backing_boo: (IStateDecoratedVariable | undefined)) get __backing_boo(): (IStateDecoratedVariable | undefined) + set __options_has_boo(__options_has_boo: (boolean | undefined)) + + get __options_has_boo(): (boolean | undefined) } diff --git a/arkui-plugins/test/ut/ui-plugins/double-dollar/double-dollar-toggle.test.ts b/arkui-plugins/test/ut/ui-plugins/double-dollar/double-dollar-toggle.test.ts index 2688f3be50a0aea1e0e0283a524bf46815e707e3..4093dfe60b4411e5ed0a891614c66c25575209c9 100644 --- a/arkui-plugins/test/ut/ui-plugins/double-dollar/double-dollar-toggle.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/double-dollar/double-dollar-toggle.test.ts @@ -138,12 +138,18 @@ class BooleanClass { set __backing_boo(__backing_boo: (IStateDecoratedVariable> | undefined)) get __backing_boo(): (IStateDecoratedVariable> | undefined) + set __options_has_boo(__options_has_boo: (boolean | undefined)) + + get __options_has_boo(): (boolean | undefined) set booClass(booClass: (BooleanClass | undefined)) get booClass(): (BooleanClass | undefined) set __backing_booClass(__backing_booClass: (IStateDecoratedVariable | undefined)) get __backing_booClass(): (IStateDecoratedVariable | undefined) + set __options_has_booClass(__options_has_booClass: (boolean | undefined)) + + get __options_has_booClass(): (boolean | undefined) } `; diff --git a/arkui-plugins/test/ut/ui-plugins/imports/import-struct.test.ts b/arkui-plugins/test/ut/ui-plugins/imports/import-struct.test.ts index f72ccb65e1f5ab8466a7e4c6365bf41744db5e65..ce4464113b1be4937022a2e4f31b3f4c549949a9 100644 --- a/arkui-plugins/test/ut/ui-plugins/imports/import-struct.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/imports/import-struct.test.ts @@ -92,6 +92,7 @@ function main() {} return new SimpleStruct(); }), { message: "str1", + __options_has_message: true, }, undefined, undefined); SimpleStruct._instantiateImpl(undefined, (() => { return new SimpleStruct(); diff --git a/arkui-plugins/test/ut/ui-plugins/imports/kit-import.test.ts b/arkui-plugins/test/ut/ui-plugins/imports/kit-import.test.ts index 62b772f7ad976b7d0b264043fa60cf0a61077d96..53273251f99937da7469716bea19d01479f5bb32 100644 --- a/arkui-plugins/test/ut/ui-plugins/imports/kit-import.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/imports/kit-import.test.ts @@ -46,7 +46,7 @@ import { EntryPoint as EntryPoint } from "arkui.UserView"; import { CustomComponent as CustomComponent } from "arkui.component.customComponent"; -import { Prop as Prop, Column as Column, Entry as Entry } from "@kit.ArkUI"; +import { PropRef as PropRef, Column as Column, Entry as Entry } from "@kit.ArkUI"; import { Text as Text, Component as Component, ClickEvent as ClickEvent } from "@ohos.arkui.component"; @@ -59,7 +59,7 @@ import hilog from "@ohos.hilog"; @Entry() @Component() final struct A extends CustomComponent implements PageLifeCycle { @State() public a: string = "str"; - @Prop() public b!: string; + @PropRef() public b!: string; public build() { Column(){ @@ -75,8 +75,10 @@ import hilog from "@ohos.hilog"; @Entry() @Component() export interface __Options_A { a?: string; @State() __backing_a?: string; + __options_has_a?: boolean; b?: string; - @Prop() __backing_b?: string; + @PropRef() __backing_b?: string; + __options_has_b?: boolean; } @@ -98,8 +100,7 @@ __EntryWrapper.RegisterNamedRouter("", new __EntryWrapper(), ({ `; const expectedCheckedScript: string = ` - -import { IPropDecoratedVariable as IPropDecoratedVariable } from "arkui.stateManagement.decorator"; +import { IPropRefDecoratedVariable as IPropRefDecoratedVariable } from "arkui.stateManagement.decorator"; import { STATE_MGMT_FACTORY as STATE_MGMT_FACTORY } from "arkui.stateManagement.decorator"; @@ -119,7 +120,7 @@ import { EntryPoint as EntryPoint } from "arkui.UserView"; import { CustomComponent as CustomComponent } from "arkui.component.customComponent"; -import { Prop as Prop, Column as Column, Entry as Entry } from "@kit.ArkUI"; +import { PropRef as PropRef, Column as Column, Entry as Entry } from "@kit.ArkUI"; import { Text as Text, Component as Component, ClickEvent as ClickEvent } from "@ohos.arkui.component"; @@ -143,12 +144,12 @@ __EntryWrapper.RegisterNamedRouter("", new __EntryWrapper(), ({ public __initializeStruct(initializers: (__Options_A | undefined), @memo() content: ((()=> void) | undefined)): void { this.__backing_a = STATE_MGMT_FACTORY.makeState(this, "a", ((({let gensym___94024326 = initializers; (((gensym___94024326) == (null)) ? undefined : gensym___94024326.a)})) ?? ("str"))); - this.__backing_b = STATE_MGMT_FACTORY.makeProp(this, "b", (initializers!.b as string)); + this.__backing_b = STATE_MGMT_FACTORY.makePropRef(this, "b", (initializers!.b as string)); } public __updateStruct(initializers: (__Options_A | undefined)): void { - if (((({let gensym___81454501 = initializers; - (((gensym___81454501) == (null)) ? undefined : gensym___81454501.b)})) !== (undefined))) { + if (({let gensym___146630597 = initializers; + (((gensym___146630597) == (null)) ? undefined : gensym___146630597.__options_has_b)})) { this.__backing_b!.update((initializers!.b as string)); } } @@ -163,7 +164,7 @@ __EntryWrapper.RegisterNamedRouter("", new __EntryWrapper(), ({ this.__backing_a!.set(value); } - private __backing_b?: IPropDecoratedVariable; + private __backing_b?: IPropRefDecoratedVariable; public get b(): string { return this.__backing_b!.get(); @@ -197,12 +198,18 @@ __EntryWrapper.RegisterNamedRouter("", new __EntryWrapper(), ({ set __backing_a(__backing_a: (IStateDecoratedVariable | undefined)) get __backing_a(): (IStateDecoratedVariable | undefined) + set __options_has_a(__options_has_a: (boolean | undefined)) + + get __options_has_a(): (boolean | undefined) set b(b: (string | undefined)) get b(): (string | undefined) - set __backing_b(__backing_b: (IPropDecoratedVariable | undefined)) + set __backing_b(__backing_b: (IPropRefDecoratedVariable | undefined)) + + get __backing_b(): (IPropRefDecoratedVariable | undefined) + set __options_has_b(__options_has_b: (boolean | undefined)) - get __backing_b(): (IPropDecoratedVariable | undefined) + get __options_has_b(): (boolean | undefined) } diff --git a/arkui-plugins/test/ut/ui-plugins/wrap-builder/builder-in-generic.test.ts b/arkui-plugins/test/ut/ui-plugins/wrap-builder/builder-in-generic.test.ts index c8334a9c9c74fbcfc4c7c32757fdbb9435464c89..235ff97e59f2b7c5152a38e6970c68c370a22cfc 100644 --- a/arkui-plugins/test/ut/ui-plugins/wrap-builder/builder-in-generic.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/wrap-builder/builder-in-generic.test.ts @@ -106,6 +106,8 @@ __EntryWrapper.RegisterNamedRouter(\"\", new __EntryWrapper(), ({ get message(): (string | undefined) set __backing_message(__backing_message: (IStateDecoratedVariable | undefined)) get __backing_message(): (IStateDecoratedVariable | undefined) + set __options_has_message(__options_has_message: (boolean | undefined)) + get __options_has_message(): (boolean | undefined) } class __EntryWrapper extends EntryPoint { @memo() public entry(): void { @@ -266,6 +268,8 @@ __EntryWrapper.RegisterNamedRouter(\"\", new __EntryWrapper(), ({ get message(): (string | undefined) set __backing_message(__backing_message: (IStateDecoratedVariable | undefined)) get __backing_message(): (IStateDecoratedVariable | undefined) + set __options_has_message(__options_has_message: (boolean | undefined)) + get __options_has_message(): (boolean | undefined) } class __EntryWrapper extends EntryPoint { @memo() public entry(__memo_context: __memo_context_type, __memo_id: __memo_id_type): void { diff --git a/arkui-plugins/test/ut/ui-plugins/wrap-builder/wrap-builder-in-generic.test.ts b/arkui-plugins/test/ut/ui-plugins/wrap-builder/wrap-builder-in-generic.test.ts index 905a8dad5bc0412a5d4eadef1734cfc68c4d272d..9c2476a882a76f6279f3f9973648d3d357441002 100644 --- a/arkui-plugins/test/ut/ui-plugins/wrap-builder/wrap-builder-in-generic.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/wrap-builder/wrap-builder-in-generic.test.ts @@ -106,10 +106,16 @@ __EntryWrapper.RegisterNamedRouter(\"\", new __EntryWrapper(), ({ public constructor() {} } @Entry({useSharedStorage:false,storage:\"\",routeName:\"\"}) @Component() export interface __Options_Index { - set message(message: (string | undefined)) - get message(): (string | undefined) - set __backing_message(__backing_message: (IStateDecoratedVariable | undefined)) - get __backing_message(): (IStateDecoratedVariable | undefined) + set message(message: (string | undefined)) + + get message(): (string | undefined) + set __backing_message(__backing_message: (IStateDecoratedVariable | undefined)) + + get __backing_message(): (IStateDecoratedVariable | undefined) + set __options_has_message(__options_has_message: (boolean | undefined)) + + get __options_has_message(): (boolean | undefined) + } class __EntryWrapper extends EntryPoint { @memo() public entry(): void { @@ -270,10 +276,16 @@ __EntryWrapper.RegisterNamedRouter(\"\", new __EntryWrapper(), ({ public constructor() {} } @Entry({useSharedStorage:false,storage:\"\",routeName:\"\"}) @Component() export interface __Options_Index { - set message(message: (string | undefined)) - get message(): (string | undefined) - set __backing_message(__backing_message: (IStateDecoratedVariable | undefined)) - get __backing_message(): (IStateDecoratedVariable | undefined) + set message(message: (string | undefined)) + + get message(): (string | undefined) + set __backing_message(__backing_message: (IStateDecoratedVariable | undefined)) + + get __backing_message(): (IStateDecoratedVariable | undefined) + set __options_has_message(__options_has_message: (boolean | undefined)) + + get __options_has_message(): (boolean | undefined) + } class __EntryWrapper extends EntryPoint { @memo() public entry(__memo_context: __memo_context_type, __memo_id: __memo_id_type): void { diff --git a/arkui-plugins/test/ut/ui-plugins/wrap-builder/wrap-builder-in-ui.test.ts b/arkui-plugins/test/ut/ui-plugins/wrap-builder/wrap-builder-in-ui.test.ts index 30038d9d3635e08418e7185e541dbb02a6d48865..dd496d6aa7db8f279ab56dd11ba1790c2ef5d46e 100644 --- a/arkui-plugins/test/ut/ui-plugins/wrap-builder/wrap-builder-in-ui.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/wrap-builder/wrap-builder-in-ui.test.ts @@ -65,8 +65,6 @@ function main() {} }), value, undefined, undefined); } -globalBuilderArr = [wrapBuilder(myBuilder), wrapBuilder(yourBuilder)]; - @memo() type MyBuilderFuncType = @Builder() ((value: string, size: number)=> void); @Component() final struct ImportStruct extends CustomComponent { @@ -169,8 +167,6 @@ function main() {} } } -globalBuilderArr = [wrapBuilder(myBuilder), wrapBuilder(yourBuilder)]; - @memo() type MyBuilderFuncType = @Builder() ((__memo_context: __memo_context_type, __memo_id: __memo_id_type, value: string, size: number)=> void); @Component() final struct ImportStruct extends CustomComponent { diff --git a/arkui-plugins/test/ut/ui-plugins/wrap-builder/wrap-builder-with-lambda.test.ts b/arkui-plugins/test/ut/ui-plugins/wrap-builder/wrap-builder-with-lambda.test.ts index ab0ee2fdf46d859c8475522f9ca9df932792a20d..5d2ae690d566fe74655db3ca92cfb1e300cac924 100644 --- a/arkui-plugins/test/ut/ui-plugins/wrap-builder/wrap-builder-with-lambda.test.ts +++ b/arkui-plugins/test/ut/ui-plugins/wrap-builder/wrap-builder-with-lambda.test.ts @@ -78,8 +78,6 @@ function main() {} })); } -wBuilder = wrapBuilder(overBuilder); - @Observed() class Tmp implements IObservedObject, ISubscribedWatches { @JSONStringifyIgnore() private subscribedWatches: ISubscribedWatches = STATE_MGMT_FACTORY.makeSubscribedWatches(); @@ -175,6 +173,9 @@ wBuilder = wrapBuilder(overBuilder); set __backing_label(__backing_label: (IStateDecoratedVariable | undefined)) get __backing_label(): (IStateDecoratedVariable | undefined) + set __options_has_label(__options_has_label: (boolean | undefined)) + + get __options_has_label(): (boolean | undefined) } `; @@ -245,8 +246,6 @@ function main() {} } } -wBuilder = wrapBuilder(overBuilder); - @Observed() class Tmp implements IObservedObject, ISubscribedWatches { @JSONStringifyIgnore() private subscribedWatches: ISubscribedWatches = STATE_MGMT_FACTORY.makeSubscribedWatches(); @@ -369,6 +368,9 @@ wBuilder = wrapBuilder(overBuilder); set __backing_label(__backing_label: (IStateDecoratedVariable | undefined)) get __backing_label(): (IStateDecoratedVariable | undefined) + set __options_has_label(__options_has_label: (boolean | undefined)) + + get __options_has_label(): (boolean | undefined) } `; diff --git a/arkui-plugins/ui-plugins/builder-lambda-translators/factory.ts b/arkui-plugins/ui-plugins/builder-lambda-translators/factory.ts index dd3a647aaf3ea2ee19e8349cc58e52fc8a0284f6..2258b37e1da9b743cd6a3caabb79bc054a2a53d1 100644 --- a/arkui-plugins/ui-plugins/builder-lambda-translators/factory.ts +++ b/arkui-plugins/ui-plugins/builder-lambda-translators/factory.ts @@ -14,7 +14,7 @@ */ import * as arkts from '@koalaui/libarkts'; -import { BuilderLambdaNames } from '../utils'; +import { BuilderLambdaNames, optionsHasField } from '../utils'; import { backingField, filterDefined, @@ -22,6 +22,7 @@ import { removeAnnotationByName, forEachArgWithParam, annotation, + collect, } from '../../common/arkts-utils'; import { BuilderLambdaDeclInfo, @@ -46,6 +47,7 @@ import { BuilderLambdaConditionBranchInfo, BuilderLambdaChainingCallArgInfo, getArgumentType, + OptionsPropertyInfo, } from './utils'; import { hasDecorator, isDecoratorIntrinsicAnnotation } from '../property-translators/utils'; import { factory as PropertyFactory } from '../property-translators/factory'; @@ -300,7 +302,10 @@ export class factory { /** * transform options argument in a builder lambda call. */ - static processOptionsArg(arg: T, typeName: string): T { + static processOptionsArg( + arg: T, + declInfo?: BuilderLambdaDeclInfo + ): T { let expr: arkts.ObjectExpression | undefined; if (arkts.isTSAsExpression(arg) && !!arg.expr && arkts.isObjectExpression(arg.expr)) { expr = arg.expr; @@ -316,12 +321,12 @@ export class factory { property = BuilderFactory.rewriteBuilderProperty(currNode); return property; }); - return factory.updatePropertiesInOptions(property); + return factory.updatePropertiesInOptions(property, declInfo); }); const updatedExpr: arkts.ObjectExpression = arkts.ObjectExpression.updateObjectExpression( expr, arkts.Es2pandaAstNodeType.AST_NODE_TYPE_OBJECT_EXPRESSION, - properties, + collect(...properties), false ); if (arkts.isTSAsExpression(arg)) { @@ -330,37 +335,60 @@ export class factory { return updatedExpr as T; } - static updatePropertiesInOptions(prop: arkts.Property): arkts.Property { - let decl: arkts.AstNode | undefined; - if (!prop.key || !prop.value || !(decl = arkts.getDecl(prop.key)) || !arkts.isMethodDefinition(decl)) { - return prop; + static updatePropertiesInOptions(prop: arkts.Property, declInfo?: BuilderLambdaDeclInfo): arkts.Property[] { + const key: arkts.AstNode | undefined = prop.key; + const value: arkts.Expression | undefined = prop.value; + if (!key || !arkts.isIdentifier(key) || !value) { + return [prop]; + } + const propertyDecl: arkts.AstNode | undefined = arkts.getDecl(key); + if (!propertyDecl || !arkts.isMethodDefinition(propertyDecl)) { + return [prop]; } let isBuilderParam: boolean = false; let isLinkIntrinsic: boolean = false; - decl.scriptFunction.annotations.forEach((anno) => { + propertyDecl.scriptFunction.annotations.forEach((anno) => { isBuilderParam ||= isDecoratorAnnotation(anno, DecoratorNames.BUILDER_PARAM); isLinkIntrinsic ||= isDecoratorIntrinsicAnnotation(anno, DecoratorIntrinsicNames.LINK); }); + return factory.updateSpecificProperties(prop, key, value, { isBuilderParam, isLinkIntrinsic }, declInfo); + } - if (isDoubleDollarCall(prop.value)) { - return factory.updateBindableProperty(prop); - } else if (isBuilderParam && arkts.isArrowFunctionExpression(prop.value)) { - addMemoAnnotation(prop.value); - return prop; + static updateSpecificProperties( + prop: arkts.Property, + key: arkts.Identifier, + value: arkts.Expression, + propertyInfo: OptionsPropertyInfo, + declInfo?: BuilderLambdaDeclInfo + ): arkts.Property[] { + const keyName: string = key.name; + let newProperty: arkts.Property = prop; + if (isDoubleDollarCall(value)) { + newProperty = factory.updateBindableProperty(prop); + } else if (propertyInfo.isBuilderParam && arkts.isArrowFunctionExpression(value)) { + addMemoAnnotation(value); + newProperty = prop; } else if ( - isLinkIntrinsic && - arkts.isIdentifier(prop.key) && - arkts.isMemberExpression(prop.value) && - arkts.isThisExpression(prop.value.object) && - arkts.isIdentifier(prop.value.property) + propertyInfo.isLinkIntrinsic && + arkts.isMemberExpression(value) && + arkts.isThisExpression(value.object) && + arkts.isIdentifier(value.property) ) { - return arkts.Property.updateProperty( + newProperty = arkts.factory.updateProperty( prop, - arkts.factory.createIdentifier(backingField(prop.key.name)), - factory.updateBackingMember(prop.value, prop.value.property.name) + arkts.factory.createIdentifier(backingField(keyName)), + factory.updateBackingMember(value, value.property.name) ); } - return prop; + return declInfo?.isFunctionCall + ? [newProperty] + : [ + newProperty, + arkts.factory.createProperty( + arkts.factory.createIdentifier(optionsHasField(keyName)), + arkts.factory.createBooleanLiteral(true) + ), + ]; } /** @@ -371,7 +399,8 @@ export class factory { fallback: arkts.AstNode | undefined, arg: arkts.Expression | undefined, typeName?: string, - canAddMemo?: boolean + canAddMemo?: boolean, + declInfo?: BuilderLambdaDeclInfo ): arkts.AstNode | undefined { if (!arg) { return fallback; @@ -385,7 +414,7 @@ export class factory { } // this is too optimistic to check if this is an options argument... if (arkts.isTSAsExpression(arg) || arkts.isObjectExpression(arg)) { - return this.processOptionsArg(arg, typeName!); + return this.processOptionsArg(arg, declInfo); } return arg; } @@ -431,7 +460,8 @@ export class factory { arkts.factory.createUndefinedLiteral(), arg, type?.name, - canAddMemo + canAddMemo, + declInfo ); } args.push(modifiedArg); diff --git a/arkui-plugins/ui-plugins/builder-lambda-translators/utils.ts b/arkui-plugins/ui-plugins/builder-lambda-translators/utils.ts index 1d5d3737c24201564be6c7ac6d61ad3f41b8c13c..c21247f53f942151fdcdf5167b21c5b533412128 100644 --- a/arkui-plugins/ui-plugins/builder-lambda-translators/utils.ts +++ b/arkui-plugins/ui-plugins/builder-lambda-translators/utils.ts @@ -55,6 +55,11 @@ export type BuilderLambdaChainingCallArgInfo = { hasBuilder?: boolean; }; +export type OptionsPropertyInfo = { + isBuilderParam: boolean; + isLinkIntrinsic: boolean; +}; + export function buildSecondLastArgInfo( type: arkts.Identifier | undefined, isFunctionCall: boolean diff --git a/arkui-plugins/ui-plugins/component-transformer.ts b/arkui-plugins/ui-plugins/component-transformer.ts index 37db0024f5b3ea6ce69facc144e4fa580015e668..ae383cc166a70560623afcb07714d182192f6777 100644 --- a/arkui-plugins/ui-plugins/component-transformer.ts +++ b/arkui-plugins/ui-plugins/component-transformer.ts @@ -41,7 +41,7 @@ import { import { ProjectConfig } from '../common/plugin-context'; import { getEntryParams } from './entry-translators/utils'; import { factory as entryFactory } from './entry-translators/factory'; -import { hasDecoratorName, findDecoratorInfos } from './property-translators/utils'; +import { hasDecoratorName, findDecoratorInfos, DecoratorInfo } from './property-translators/utils'; import { factory } from './ui-factory'; import { factory as propertyFactory } from './property-translators/factory'; import { StructMap } from '../common/program-visitor'; @@ -454,13 +454,14 @@ export class ComponentTransformer extends AbstractVisitor { undefined, arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_PUBLIC ); - const infos = findDecoratorInfos(member); - const buildParamInfo = infos.find((it) => + const infos: DecoratorInfo[] = findDecoratorInfos(member); + const buildParamInfo: DecoratorInfo | undefined = infos.find((it) => isDecoratorAnnotation(it.annotation, DecoratorNames.BUILDER_PARAM, true) ); + const optionsHasMember = factory.createOptionsHasMember(originalName); if (!!buildParamInfo) { originMember.setAnnotations([buildParamInfo.annotation.clone()]); - return [originMember]; + return [originMember, optionsHasMember]; } const targetInfo = infos.find((it) => DECORATOR_TYPE_MAP.has(it.name)); if (!!targetInfo) { @@ -476,9 +477,9 @@ export class ComponentTransformer extends AbstractVisitor { this.shouldAddLinkIntrinsic = true; originMember.setAnnotations([annotation(DecoratorIntrinsicNames.LINK)]); } - return [originMember, newMember]; + return [originMember, newMember, optionsHasMember]; } - return [originMember]; + return [originMember, optionsHasMember]; } registerMap(map: Map): void { @@ -510,13 +511,15 @@ export class ComponentTransformer extends AbstractVisitor { } const className = ident.name; const trailingBlock = node.trailingBlock; - const content = trailingBlock ? arkts.factory.createArrowFunction( - factory.createScriptFunction({ - body: trailingBlock, - flags: arkts.Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_ARROW, - modifiers: arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_NONE, - }) - ) : undefined; + const content = trailingBlock + ? arkts.factory.createArrowFunction( + factory.createScriptFunction({ + body: trailingBlock, + flags: arkts.Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_ARROW, + modifiers: arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_NONE, + }) + ) + : undefined; if (this.legacyCallMap.has(className)) { const path = this.legacyCallMap.get(className)!; const args = node.arguments; @@ -524,7 +527,7 @@ export class ComponentTransformer extends AbstractVisitor { className: className, path: path, arguments: args && args.length === 1 && args[0] instanceof arkts.ObjectExpression ? args[0] : undefined, - content: content + content: content, }; return generateInstantiateInterop(context); } diff --git a/arkui-plugins/ui-plugins/property-translators/factory.ts b/arkui-plugins/ui-plugins/property-translators/factory.ts index b9bcba9a7d60ae5e48fb573d5f43b3b20c9274be..532bcfca71d2dbaa45765bacbf675583822f9f37 100644 --- a/arkui-plugins/ui-plugins/property-translators/factory.ts +++ b/arkui-plugins/ui-plugins/property-translators/factory.ts @@ -32,7 +32,7 @@ import { OptionalMemberInfo, removeDecorator, } from './utils'; -import { CustomComponentNames, getClassPropertyType } from '../utils'; +import { CustomComponentNames, getClassPropertyType, optionsHasField } from '../utils'; import { addMemoAnnotation, findCanAddMemoFromTypeAnnotation } from '../../collectors/memo-collectors/utils'; import { annotation, isNumeric } from '../../common/arkts-utils'; @@ -273,13 +273,10 @@ export class factory { member: arkts.Expression, args: arkts.AstNode[] ): arkts.IfStatement { - const binaryItem = arkts.factory.createBinaryExpression( - factory.createBlockStatementForOptionalExpression( - arkts.factory.createIdentifier(CustomComponentNames.COMPONENT_INITIALIZERS_NAME), - originalName - ), - arkts.factory.createUndefinedLiteral(), - arkts.Es2pandaTokenType.TOKEN_TYPE_PUNCTUATOR_NOT_STRICT_EQUAL + const initializers = arkts.factory.createIdentifier(CustomComponentNames.COMPONENT_INITIALIZERS_NAME); + const binaryItem = factory.createBlockStatementForOptionalExpression( + initializers, + optionsHasField(originalName) ); return arkts.factory.createIfStatement( binaryItem, diff --git a/arkui-plugins/ui-plugins/property-translators/index.ts b/arkui-plugins/ui-plugins/property-translators/index.ts index 914006824c8ec1c4ffbcb63e1103f23147d53c3b..ff8a89025895f1b719f6321aa71f315984bc1c8e 100644 --- a/arkui-plugins/ui-plugins/property-translators/index.ts +++ b/arkui-plugins/ui-plugins/property-translators/index.ts @@ -19,16 +19,13 @@ import { DecoratorNames } from '../../common/predefines'; import { InterfacePropertyTranslator, MethodTranslator, PropertyTranslator } from './base'; import { hasDecorator } from './utils'; import { StateInterfaceTranslator, StateTranslator } from './state'; -import { PropInterfaceTranslator, PropTranslator } from './prop'; import { StorageLinkInterfaceTranslator, StorageLinkTranslator } from './storagelink'; import { LocalStorageLinkInterfaceTranslator, LocalStorageLinkTranslator } from './localstoragelink'; import { LinkInterfaceTranslator, LinkTranslator } from './link'; import { ObjectLinkInterfaceTranslator, ObjectLinkTranslator } from './objectlink'; -import { LocalStoragePropInterfaceTranslator, LocalStoragePropTranslator } from './localstorageprop'; import { RegularInterfaceTranslator, RegularPropertyTranslator } from './regularProperty'; import { StaticPropertyTranslator } from './staticProperty'; import { CustomComponentInfo } from '../utils'; -import { StoragePropInterfaceTranslator, StoragePropTranslator } from './storageProp'; import { ConsumeInterfaceTranslator, ConsumeTranslator } from './consume'; import { ProvideInterfaceTranslator, ProvideTranslator } from './provide'; import { BuilderParamInterfaceTranslator, BuilderParamTranslator } from './builderParam'; @@ -103,21 +100,12 @@ export function classifyV1Property( if (hasDecorator(property, DecoratorNames.OBJECT_LINK)) { return new ObjectLinkTranslator({ property, structInfo }); } - if (hasDecorator(property, DecoratorNames.LOCAL_STORAGE_PROP)) { - return new LocalStoragePropTranslator({ property, structInfo }); - } if (hasDecorator(property, DecoratorNames.LOCAL_STORAGE_PROP_REF)) { return new LocalStoragePropRefTranslator({ property, structInfo }); } - if (hasDecorator(property, DecoratorNames.STORAGE_PROP)) { - return new StoragePropTranslator({ property, structInfo }); - } if (hasDecorator(property, DecoratorNames.STORAGE_PROP_REF)) { return new StoragePropRefTranslator({ property, structInfo }); } - if (hasDecorator(property, DecoratorNames.PROP)) { - return new PropTranslator({ property, structInfo }); - } if (hasDecorator(property, DecoratorNames.PROP_REF)) { return new PropRefTranslator({ property, structInfo }); } @@ -183,9 +171,6 @@ export function classifyV1PropertyInInterface(property: arkts.AstNode): Interfac if (LinkInterfaceTranslator.canBeTranslated(property)) { return new LinkInterfaceTranslator({ property }); } - if (PropInterfaceTranslator.canBeTranslated(property)) { - return new PropInterfaceTranslator({ property }); - } if (PropRefInterfaceTranslator.canBeTranslated(property)) { return new PropRefInterfaceTranslator({ property }); } @@ -195,9 +180,6 @@ export function classifyV1PropertyInInterface(property: arkts.AstNode): Interfac if (ConsumeInterfaceTranslator.canBeTranslated(property)) { return new ConsumeInterfaceTranslator({ property }); } - if (StoragePropInterfaceTranslator.canBeTranslated(property)) { - return new StoragePropInterfaceTranslator({ property }); - } if (StorageLinkInterfaceTranslator.canBeTranslated(property)) { return new StorageLinkInterfaceTranslator({ property }); } @@ -210,9 +192,6 @@ export function classifyV1PropertyInInterface(property: arkts.AstNode): Interfac if (BuilderParamInterfaceTranslator.canBeTranslated(property)) { return new BuilderParamInterfaceTranslator({ property }); } - if (LocalStoragePropInterfaceTranslator.canBeTranslated(property)) { - return new LocalStoragePropInterfaceTranslator({ property }); - } if (LocalStorageLinkInterfaceTranslator.canBeTranslated(property)) { return new LocalStorageLinkInterfaceTranslator({ property }); } diff --git a/arkui-plugins/ui-plugins/property-translators/link.ts b/arkui-plugins/ui-plugins/property-translators/link.ts index 35c50150f046a2ecbc597a6285e65285218d4fed..cd1b149bd59d5ec759e56f6889dbd8bec0e1253a 100644 --- a/arkui-plugins/ui-plugins/property-translators/link.ts +++ b/arkui-plugins/ui-plugins/property-translators/link.ts @@ -17,7 +17,7 @@ import * as arkts from '@koalaui/libarkts'; import { backingField, expectName } from '../../common/arkts-utils'; import { DecoratorNames, GetSetTypes, StateManagementTypes } from '../../common/predefines'; -import { CustomComponentNames } from '../utils'; +import { CustomComponentNames, optionsHasField } from '../utils'; import { generateToRecord, createGetter, @@ -53,7 +53,7 @@ export class LinkTranslator extends PropertyTranslator implements InitializerCon generateInitializeStruct(newName: string, originalName: string) { const test = factory.createBlockStatementForOptionalExpression( arkts.factory.createIdentifier(CustomComponentNames.COMPONENT_INITIALIZERS_NAME), - newName + optionsHasField(originalName) ); const args: arkts.Expression[] = [ diff --git a/arkui-plugins/ui-plugins/property-translators/localstorageprop.ts b/arkui-plugins/ui-plugins/property-translators/localstorageprop.ts deleted file mode 100644 index 7b5840e62f24d9e7e365605ac92fd2656b23ebfb..0000000000000000000000000000000000000000 --- a/arkui-plugins/ui-plugins/property-translators/localstorageprop.ts +++ /dev/null @@ -1,229 +0,0 @@ -/* - * 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 * as arkts from '@koalaui/libarkts'; - -import { backingField, expectName } from '../../common/arkts-utils'; -import { DecoratorNames, StateManagementTypes } from '../../common/predefines'; -import { collectStateManagementTypeImport, generateToRecord, hasDecorator } from './utils'; -import { InterfacePropertyTranslator, InterfacePropertyTypes, PropertyTranslator } from './base'; -import { GetterSetter, InitializerConstructor } from './types'; -import { factory } from './factory'; -import { PropertyCache } from './cache/propertyCache'; - -function getLocalStorageporpValueStr(node: arkts.AstNode): string | undefined { - if (!arkts.isClassProperty(node) || !node.value) return undefined; - - return arkts.isStringLiteral(node.value) ? node.value.str : undefined; -} -function getLocalStorageporpAnnotationValue(anno: arkts.AnnotationUsage): string | undefined { - const isLocalStorageporpAnnotation: boolean = - !!anno.expr && arkts.isIdentifier(anno.expr) && anno.expr.name === DecoratorNames.LOCAL_STORAGE_PROP; - - if (isLocalStorageporpAnnotation && anno.properties.length === 1) { - return getLocalStorageporpValueStr(anno.properties.at(0)!); - } - return undefined; -} - -function getLocalStorageporpValueInAnnotation(node: arkts.ClassProperty): string | undefined { - const annotations: readonly arkts.AnnotationUsage[] = node.annotations; - - for (let i = 0; i < annotations.length; i++) { - const anno: arkts.AnnotationUsage = annotations[i]; - const str: string | undefined = getLocalStorageporpAnnotationValue(anno); - if (!!str) { - return str; - } - } - - return undefined; -} - -export class LocalStoragePropTranslator extends PropertyTranslator implements InitializerConstructor, GetterSetter { - translateMember(): arkts.AstNode[] { - const originalName: string = expectName(this.property.key); - const newName: string = backingField(originalName); - - this.cacheTranslatedInitializer(newName, originalName); - return this.translateWithoutInitializer(newName, originalName); - } - - cacheTranslatedInitializer(newName: string, originalName: string): void { - const initializeStruct: arkts.AstNode = this.generateInitializeStruct(newName, originalName); - PropertyCache.getInstance().collectInitializeStruct(this.structInfo.name, [initializeStruct]); - const updateStruct: arkts.AstNode = this.generateUpdateStruct(newName, originalName); - PropertyCache.getInstance().collectUpdateStruct(this.structInfo.name, [updateStruct]); - if (!!this.structInfo.annotations?.reusable) { - const toRecord = generateToRecord(newName, originalName); - PropertyCache.getInstance().collectToRecord(this.structInfo.name, [toRecord]); - } - } - - translateWithoutInitializer(newName: string, originalName: string): arkts.AstNode[] { - const field = factory.createOptionalClassProperty( - newName, - this.property, - StateManagementTypes.SYNCED_PROPERTY, - arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_PRIVATE - ); - - const member = arkts.factory.createTSNonNullExpression( - arkts.factory.createMemberExpression( - arkts.factory.createThisExpression(), - arkts.factory.createIdentifier(newName), - arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS, - false, - false - ) - ); - const thisValue: arkts.MemberExpression = arkts.factory.createMemberExpression( - member, - arkts.factory.createIdentifier('value'), - arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS, - false, - false - ); - - const getter: arkts.MethodDefinition = this.translateGetter(originalName, this.propertyType, thisValue); - const setter: arkts.MethodDefinition = this.translateSetter(originalName, this.propertyType, thisValue); - return [field, getter, setter]; - } - - generateInitializeStruct(newName: string, originalName: string): arkts.AstNode { - const localStorageporpValueStr: string | undefined = getLocalStorageporpValueInAnnotation(this.property); - if (!localStorageporpValueStr) { - throw new Error('LocalStorageProp required only one value!!'); - } - const insideMember = arkts.factory.createMemberExpression( - arkts.factory.createThisExpression(), - arkts.factory.createIdentifier('_entry_local_storage_'), - arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS, - false, - false - ); - const binaryItem = arkts.factory.createCallExpression( - arkts.factory.createIdentifier(StateManagementTypes.STORAGE_LINK_STATE), - this.propertyType ? [this.propertyType] : [], - [ - insideMember, - arkts.factory.createStringLiteral(localStorageporpValueStr), - this.property.value ?? arkts.factory.createUndefinedLiteral(), - ] - ); - collectStateManagementTypeImport(StateManagementTypes.STORAGE_LINK_STATE); - const call = arkts.factory.createCallExpression( - arkts.factory.createIdentifier(StateManagementTypes.PROP_STATE), - this.propertyType ? [this.propertyType] : [], - [ - arkts.factory.createMemberExpression( - binaryItem, - arkts.factory.createIdentifier('value'), - arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS, - false, - false - ), - ] - ); - collectStateManagementTypeImport(StateManagementTypes.PROP_STATE); - return arkts.factory.createAssignmentExpression( - arkts.factory.createMemberExpression( - arkts.factory.createThisExpression(), - arkts.factory.createIdentifier(newName), - arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS, - false, - false - ), - arkts.Es2pandaTokenType.TOKEN_TYPE_PUNCTUATOR_SUBSTITUTION, - call - ); - } - - generateUpdateStruct(newName: string, originalName: string): arkts.AstNode { - const localStorageporpValueStr: string | undefined = getLocalStorageporpValueInAnnotation(this.property); - if (!localStorageporpValueStr) { - throw new Error('StorageLink required only one value!!'); - } - const StorageLinkStateValue = factory.createStorageLinkStateValue(this.property, localStorageporpValueStr); - collectStateManagementTypeImport(StateManagementTypes.STORAGE_LINK_STATE); - const test = arkts.factory.createMemberExpression( - arkts.factory.createThisExpression(), - arkts.factory.createIdentifier(newName), - arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS, - false, - false - ); - const consequent = arkts.BlockStatement.createBlockStatement([ - arkts.factory.createExpressionStatement( - arkts.factory.createCallExpression( - arkts.factory.createMemberExpression( - arkts.factory.createTSNonNullExpression(test), - arkts.factory.createIdentifier('update'), - arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS, - false, - false - ), - undefined, - [StorageLinkStateValue] - ) - ), - ]); - return arkts.factory.createExpressionStatement(arkts.factory.createIfStatement(test, consequent)); - } -} - -export class LocalStoragePropInterfaceTranslator< - T extends InterfacePropertyTypes -> extends InterfacePropertyTranslator { - translateProperty(): T { - if (arkts.isMethodDefinition(this.property)) { - this.modified = true; - return this.updateStateMethodInInterface(this.property) as T; - } else if (arkts.isClassProperty(this.property)) { - this.modified = true; - return this.updateStatePropertyInInterface(this.property) as T; - } - return this.property; - } - - static canBeTranslated(node: arkts.AstNode): node is InterfacePropertyTypes { - if (arkts.isMethodDefinition(node) && hasDecorator(node, DecoratorNames.LOCAL_STORAGE_PROP)) { - return true; - } else if (arkts.isClassProperty(node) && hasDecorator(node, DecoratorNames.LOCAL_STORAGE_PROP)) { - return true; - } - return false; - } - - /** - * Wrap getter's return type and setter's param type (expecting an union type with `T` and `undefined`) - * to `SyncedProperty | undefined`. - * - * @param method expecting getter with `@LocalStorageProp` and a setter with `@LocalStorageProp` in the overloads. - */ - private updateStateMethodInInterface(method: arkts.MethodDefinition): arkts.MethodDefinition { - return factory.wrapStateManagementTypeToMethodInInterface(method, DecoratorNames.LOCAL_STORAGE_PROP); - } - - /** - * Wrap to the type of the property (expecting an union type with `T` and `undefined`) - * to `SyncedProperty | undefined`. - * - * @param property expecting property with `@LocalStorageProp`. - */ - private updateStatePropertyInInterface(property: arkts.ClassProperty): arkts.ClassProperty { - return factory.wrapStateManagementTypeToPropertyInInterface(property, DecoratorNames.LOCAL_STORAGE_PROP); - } -} diff --git a/arkui-plugins/ui-plugins/property-translators/objectlink.ts b/arkui-plugins/ui-plugins/property-translators/objectlink.ts index 0e5a4b48804878e95b5109abe655d66be0d95e35..9e1612ad294597e496bf85af1afac216f905da36 100644 --- a/arkui-plugins/ui-plugins/property-translators/objectlink.ts +++ b/arkui-plugins/ui-plugins/property-translators/objectlink.ts @@ -70,13 +70,15 @@ export class ObjectLinkTranslator extends PropertyTranslator implements Initiali false, false ); - const nonNullItem = arkts.factory.createTSNonNullExpression( + const nonNullItem = arkts.factory.createTSAsExpression( factory.createNonNullOrOptionalMemberExpression( CustomComponentNames.COMPONENT_INITIALIZERS_NAME, originalName, false, true - ) + ), + this.propertyType, + false ); return factory.createIfInUpdateStruct(originalName, member, [nonNullItem]); } diff --git a/arkui-plugins/ui-plugins/property-translators/prop.ts b/arkui-plugins/ui-plugins/property-translators/prop.ts deleted file mode 100644 index f4e6fbcb1038f592abc98f3a3f301b488a9451d4..0000000000000000000000000000000000000000 --- a/arkui-plugins/ui-plugins/property-translators/prop.ts +++ /dev/null @@ -1,168 +0,0 @@ -/* - * 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 * as arkts from '@koalaui/libarkts'; - -import { backingField, expectName } from '../../common/arkts-utils'; -import { DecoratorNames, GetSetTypes, StateManagementTypes } from '../../common/predefines'; -import { CustomComponentNames } from '../utils'; -import { - collectStateManagementTypeImport, - createGetter, - createSetter2, - generateGetOrSetCall, - generateThisBacking, - generateToRecord, - hasDecorator, -} from './utils'; -import { InterfacePropertyTranslator, InterfacePropertyTypes, PropertyTranslator } from './base'; -import { GetterSetter, InitializerConstructor } from './types'; -import { factory } from './factory'; -import { PropertyCache } from './cache/propertyCache'; - -export class PropTranslator extends PropertyTranslator implements InitializerConstructor, GetterSetter { - translateMember(): arkts.AstNode[] { - const originalName: string = expectName(this.property.key); - const newName: string = backingField(originalName); - - this.cacheTranslatedInitializer(newName, originalName); - return this.translateWithoutInitializer(newName, originalName); - } - - cacheTranslatedInitializer(newName: string, originalName: string): void { - const mutableThis: arkts.Expression = generateThisBacking(newName); - const initializeStruct: arkts.AstNode = this.generateInitializeStruct(newName, originalName); - PropertyCache.getInstance().collectInitializeStruct(this.structInfo.name, [initializeStruct]); - const updateStruct: arkts.AstNode = this.generateUpdateStruct(mutableThis, originalName); - PropertyCache.getInstance().collectUpdateStruct(this.structInfo.name, [updateStruct]); - if (!!this.structInfo.annotations?.reusable) { - const toRecord = generateToRecord(newName, originalName); - PropertyCache.getInstance().collectToRecord(this.structInfo.name, [toRecord]); - } - } - - translateWithoutInitializer(newName: string, originalName: string): arkts.AstNode[] { - const field: arkts.ClassProperty = factory.createOptionalClassProperty( - newName, - this.property, - StateManagementTypes.PROP_DECORATED, - arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_PRIVATE - ); - const thisValue: arkts.Expression = generateThisBacking(newName, false, true); - const thisGet: arkts.CallExpression = generateGetOrSetCall(thisValue, GetSetTypes.GET); - const thisSet: arkts.ExpressionStatement = arkts.factory.createExpressionStatement( - generateGetOrSetCall(thisValue, GetSetTypes.SET) - ); - const getter: arkts.MethodDefinition = this.translateGetter(originalName, this.propertyType, thisGet); - const setter: arkts.MethodDefinition = this.translateSetter(originalName, this.propertyType, thisSet); - - return [field, getter, setter]; - } - - translateGetter( - originalName: string, - typeAnnotation: arkts.TypeNode | undefined, - returnValue: arkts.Expression - ): arkts.MethodDefinition { - return createGetter(originalName, typeAnnotation, returnValue); - } - - translateSetter( - originalName: string, - typeAnnotation: arkts.TypeNode | undefined, - statement: arkts.AstNode - ): arkts.MethodDefinition { - return createSetter2(originalName, typeAnnotation, statement); - } - - generateInitializeStruct(newName: string, originalName: string): arkts.AstNode { - const args: arkts.Expression[] = [ - arkts.factory.create1StringLiteral(originalName), - factory.generateInitializeValue(this.property, this.propertyType, originalName), - ]; - factory.judgeIfAddWatchFunc(args, this.property); - collectStateManagementTypeImport(StateManagementTypes.PROP_DECORATED); - const assign: arkts.AssignmentExpression = arkts.factory.createAssignmentExpression( - generateThisBacking(newName), - arkts.Es2pandaTokenType.TOKEN_TYPE_PUNCTUATOR_SUBSTITUTION, - factory.generateStateMgmtFactoryCall(StateManagementTypes.MAKE_PROP, this.propertyType, args, true) - ); - return arkts.factory.createExpressionStatement(assign); - } - - generateUpdateStruct(mutableThis: arkts.Expression, originalName: string): arkts.AstNode { - const member: arkts.MemberExpression = arkts.factory.createMemberExpression( - arkts.factory.createTSNonNullExpression(mutableThis), - arkts.factory.createIdentifier(StateManagementTypes.UPDATE), - arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS, - false, - false - ); - return factory.createIfInUpdateStruct(originalName, member, [ - arkts.factory.createTSAsExpression( - factory.createNonNullOrOptionalMemberExpression( - CustomComponentNames.COMPONENT_INITIALIZERS_NAME, - originalName, - false, - true - ), - this.propertyType, - false - ), - ]); - } -} - -export class PropInterfaceTranslator extends InterfacePropertyTranslator { - translateProperty(): T { - if (arkts.isMethodDefinition(this.property)) { - this.modified = true; - return this.updateStateMethodInInterface(this.property) as T; - } else if (arkts.isClassProperty(this.property)) { - this.modified = true; - return this.updateStatePropertyInInterface(this.property) as T; - } - return this.property; - } - - static canBeTranslated(node: arkts.AstNode): node is InterfacePropertyTypes { - if (arkts.isMethodDefinition(node) && hasDecorator(node, DecoratorNames.PROP)) { - return true; - } else if (arkts.isClassProperty(node) && hasDecorator(node, DecoratorNames.PROP)) { - return true; - } - return false; - } - - /** - * Wrap getter's return type and setter's param type (expecting an union type with `T` and `undefined`) - * to `PropDecoratedVariable | undefined`. - * - * @param method expecting getter with `@Prop` and a setter with `@Prop` in the overloads. - */ - private updateStateMethodInInterface(method: arkts.MethodDefinition): arkts.MethodDefinition { - return factory.wrapStateManagementTypeToMethodInInterface(method, DecoratorNames.PROP); - } - - /** - * Wrap to the type of the property (expecting an union type with `T` and `undefined`) - * to `PropDecoratedVariable | undefined`. - * - * @param property expecting property with `@Prop`. - */ - private updateStatePropertyInInterface(property: arkts.ClassProperty): arkts.ClassProperty { - return factory.wrapStateManagementTypeToPropertyInInterface(property, DecoratorNames.PROP); - } -} diff --git a/arkui-plugins/ui-plugins/property-translators/storageProp.ts b/arkui-plugins/ui-plugins/property-translators/storageProp.ts deleted file mode 100644 index e4b0978d2f40629895d1f76d9d88aae656a74086..0000000000000000000000000000000000000000 --- a/arkui-plugins/ui-plugins/property-translators/storageProp.ts +++ /dev/null @@ -1,156 +0,0 @@ -/* - * 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 * as arkts from '@koalaui/libarkts'; - -import { backingField, expectName } from '../../common/arkts-utils'; -import { DecoratorNames, GetSetTypes, StateManagementTypes } from '../../common/predefines'; -import { InterfacePropertyTranslator, InterfacePropertyTypes, PropertyTranslator } from './base'; -import { GetterSetter, InitializerConstructor } from './types'; -import { - generateToRecord, - createGetter, - createSetter2, - generateThisBacking, - generateGetOrSetCall, - collectStateManagementTypeImport, - hasDecorator, - getValueInAnnotation, -} from './utils'; -import { factory } from './factory'; -import { PropertyCache } from './cache/propertyCache'; - -export class StoragePropTranslator extends PropertyTranslator implements InitializerConstructor, GetterSetter { - translateMember(): arkts.AstNode[] { - const originalName: string = expectName(this.property.key); - const newName: string = backingField(originalName); - - this.cacheTranslatedInitializer(newName, originalName); - return this.translateWithoutInitializer(newName, originalName); - } - - cacheTranslatedInitializer(newName: string, originalName: string): void { - const initializeStruct: arkts.AstNode = this.generateInitializeStruct(newName, originalName); - PropertyCache.getInstance().collectInitializeStruct(this.structInfo.name, [initializeStruct]); - if (!!this.structInfo.annotations?.reusable) { - const toRecord = generateToRecord(newName, originalName); - PropertyCache.getInstance().collectToRecord(this.structInfo.name, [toRecord]); - } - } - - generateInitializeStruct(newName: string, originalName: string): arkts.AstNode { - const storagePropValueStr: string | undefined = getValueInAnnotation( - this.property, - DecoratorNames.STORAGE_PROP - ); - if (!storagePropValueStr) { - throw new Error('StorageProp required only one value!!'); - } - - const args: arkts.Expression[] = [ - arkts.factory.createStringLiteral(storagePropValueStr), - arkts.factory.create1StringLiteral(originalName), - this.property.value ?? arkts.factory.createUndefinedLiteral(), - ]; - factory.judgeIfAddWatchFunc(args, this.property); - collectStateManagementTypeImport(StateManagementTypes.STORAGE_PROP_REF_DECORATED); - - return arkts.factory.createAssignmentExpression( - generateThisBacking(newName), - arkts.Es2pandaTokenType.TOKEN_TYPE_PUNCTUATOR_SUBSTITUTION, - factory.generateStateMgmtFactoryCall( - StateManagementTypes.MAKE_STORAGE_PROP_REF, - this.propertyType, - args, - true - ) - ); - } - - translateWithoutInitializer(newName: string, originalName: string): arkts.AstNode[] { - const field = factory.createOptionalClassProperty( - newName, - this.property, - StateManagementTypes.STORAGE_PROP_REF_DECORATED, - arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_PRIVATE - ); - const thisValue: arkts.Expression = generateThisBacking(newName, false, true); - const thisGet: arkts.CallExpression = generateGetOrSetCall(thisValue, GetSetTypes.GET); - const thisSet: arkts.ExpressionStatement = arkts.factory.createExpressionStatement( - generateGetOrSetCall(thisValue, GetSetTypes.SET) - ); - const getter: arkts.MethodDefinition = this.translateGetter(originalName, this.propertyType, thisGet); - const setter: arkts.MethodDefinition = this.translateSetter(originalName, this.propertyType, thisSet); - return [field, getter, setter]; - } - - translateGetter( - originalName: string, - typeAnnotation: arkts.TypeNode | undefined, - returnValue: arkts.Expression - ): arkts.MethodDefinition { - return createGetter(originalName, typeAnnotation, returnValue); - } - - translateSetter( - originalName: string, - typeAnnotation: arkts.TypeNode | undefined, - statement: arkts.AstNode - ): arkts.MethodDefinition { - return createSetter2(originalName, typeAnnotation, statement); - } -} - -export class StoragePropInterfaceTranslator extends InterfacePropertyTranslator { - translateProperty(): T { - if (arkts.isMethodDefinition(this.property)) { - this.modified = true; - return this.updateStateMethodInInterface(this.property) as T; - } else if (arkts.isClassProperty(this.property)) { - this.modified = true; - return this.updateStatePropertyInInterface(this.property) as T; - } - return this.property; - } - - static canBeTranslated(node: arkts.AstNode): node is InterfacePropertyTypes { - if (arkts.isMethodDefinition(node) && hasDecorator(node, DecoratorNames.STORAGE_PROP)) { - return true; - } else if (arkts.isClassProperty(node) && hasDecorator(node, DecoratorNames.STORAGE_PROP)) { - return true; - } - return false; - } - - /** - * Wrap getter's return type and setter's param type (expecting an union type with `T` and `undefined`) - * to `StoragePropDecoratedVariable | undefined`. - * - * @param method expecting getter with `@StorageProp` and a setter with `@StorageProp` in the overloads. - */ - private updateStateMethodInInterface(method: arkts.MethodDefinition): arkts.MethodDefinition { - return factory.wrapStateManagementTypeToMethodInInterface(method, DecoratorNames.STORAGE_PROP); - } - - /** - * Wrap to the type of the property (expecting an union type with `T` and `undefined`) - * to `StoragePropDecoratedVariable | undefined`. - * - * @param property expecting property with `@StorageProp`. - */ - private updateStatePropertyInInterface(property: arkts.ClassProperty): arkts.ClassProperty { - return factory.wrapStateManagementTypeToPropertyInInterface(property, DecoratorNames.STORAGE_PROP); - } -} diff --git a/arkui-plugins/ui-plugins/property-translators/utils.ts b/arkui-plugins/ui-plugins/property-translators/utils.ts index 8e4415efe359cd19db4c6b23481e129063e3c8c6..186a353bcb528ba02f6fc86199a908403bd5d3f3 100644 --- a/arkui-plugins/ui-plugins/property-translators/utils.ts +++ b/arkui-plugins/ui-plugins/property-translators/utils.ts @@ -125,7 +125,6 @@ export function needDefiniteOrOptionalModifier(st: arkts.ClassProperty): boolean hasDecoratorName(st, DecoratorNames.LINK) || hasDecoratorName(st, DecoratorNames.CONSUME) || hasDecoratorName(st, DecoratorNames.OBJECT_LINK) || - (hasDecoratorName(st, DecoratorNames.PROP) && !st.value) || (hasDecoratorName(st, DecoratorNames.PROP_REF) && !st.value) || (hasDecoratorName(st, DecoratorNames.PARAM) && !st.value) || (hasDecoratorName(st, DecoratorNames.EVENT) && !st.value) || diff --git a/arkui-plugins/ui-plugins/ui-factory.ts b/arkui-plugins/ui-plugins/ui-factory.ts index 8b7280f0d1ed34a377f7a6cea0e0bb900ea8c065..14d0e290acdae1aa414fc43b02c2d325a049d022 100644 --- a/arkui-plugins/ui-plugins/ui-factory.ts +++ b/arkui-plugins/ui-plugins/ui-factory.ts @@ -21,6 +21,7 @@ import { CustomDialogNames, hasNullOrUndefinedType, hasPropertyInAnnotation, + optionsHasField, } from './utils'; import { PartialExcept, PartialNested, PartialNestedExcept } from '../common/safe-types'; import { ArkTsDefaultNames, DecoratorNames } from '../common/predefines'; @@ -488,4 +489,19 @@ export class factory { ) ); } + + /** + * create `__Options_has_` class property. + */ + static createOptionsHasMember(name: string): arkts.ClassProperty { + const optionsHasMember: arkts.ClassProperty = arkts.factory.createClassProperty( + arkts.factory.createIdentifier(optionsHasField(name)), + undefined, + arkts.factory.createPrimitiveType(arkts.Es2pandaPrimitiveType.PRIMITIVE_TYPE_BOOLEAN), + arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_PUBLIC, + false + ); + arkts.classPropertySetOptional(optionsHasMember, true); + return optionsHasMember; + } } diff --git a/arkui-plugins/ui-plugins/utils.ts b/arkui-plugins/ui-plugins/utils.ts index 210a2aeabfcb7278c9972cb004ae289e2e3334ae..c6fc41193f298c0766aae9b68389e40c667a8373 100644 --- a/arkui-plugins/ui-plugins/utils.ts +++ b/arkui-plugins/ui-plugins/utils.ts @@ -373,6 +373,10 @@ export function monitorField(name: string): string { return `__monitor_${name}`; } +export function optionsHasField(name: string): string { + return `__options_has_${name}`; +} + export function getClassPropertyType(property: arkts.ClassProperty): arkts.TypeNode | undefined { const type = property.typeAnnotation; if (!!type) {