mirror of
https://github.com/openharmony/developtools_ace-ets2bundle.git
synced 2026-07-19 16:43:34 -04:00
!215 修改自定义builder bug
Merge pull request !215 from 蒲亚军/cherry-pick-1642673174
This commit is contained in:
@@ -177,7 +177,8 @@ export function processComponentChild(node: ts.Block | ts.SourceFile, newStateme
|
||||
case ComponentType.forEachComponent:
|
||||
processForEachComponent(item, newStatements, log);
|
||||
break;
|
||||
case ComponentType.customBuilderMethod || ComponentType.builderParamMethod:
|
||||
case ComponentType.customBuilderMethod:
|
||||
case ComponentType.builderParamMethod:
|
||||
newStatements.push(item);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ export const setUpdateParamsDecorators: Set<string> =
|
||||
]);
|
||||
|
||||
export const immutableDecorators: Set<string> =
|
||||
new Set([COMPONENT_STORAGE_PROP_DECORATOR, COMPONENT_OBJECT_LINK_DECORATOR]);
|
||||
new Set([COMPONENT_STORAGE_PROP_DECORATOR, COMPONENT_OBJECT_LINK_DECORATOR, COMPONENT_BUILDERPARAM_DECORATOR]);
|
||||
|
||||
export const simpleTypes: Set<ts.SyntaxKind> = new Set([ts.SyntaxKind.StringKeyword,
|
||||
ts.SyntaxKind.NumberKeyword, ts.SyntaxKind.BooleanKeyword, ts.SyntaxKind.EnumDeclaration]);
|
||||
@@ -299,14 +299,16 @@ function processStateDecorators(node: ts.PropertyDeclaration, decorator: string,
|
||||
}
|
||||
addAddProvidedVar(node, name, decorator, updateState);
|
||||
updateResult.setCtor(updateConstructor(ctorNode, [], [...updateState], false));
|
||||
updateResult.setVariableGet(createGetAccessor(name, CREATE_GET_METHOD));
|
||||
if (decorator !== COMPONENT_BUILDERPARAM_DECORATOR) {
|
||||
updateResult.setVariableGet(createGetAccessor(name, CREATE_GET_METHOD));
|
||||
updateResult.setDeleteParams(true);
|
||||
}
|
||||
if (!immutableDecorators.has(decorator)) {
|
||||
updateResult.setVariableSet(createSetAccessor(name, CREATE_SET_METHOD));
|
||||
}
|
||||
if (setUpdateParamsDecorators.has(decorator)) {
|
||||
updateResult.setUpdateParams(createUpdateParams(name, decorator));
|
||||
}
|
||||
updateResult.setDeleteParams(true);
|
||||
}
|
||||
|
||||
function processWatch(node: ts.PropertyDeclaration, decorator: ts.Decorator,
|
||||
@@ -436,14 +438,8 @@ function createUpdateParamsWithIf(name: ts.Identifier): ts.IfStatement {
|
||||
}
|
||||
|
||||
function createUpdateParamsWithoutIf(name: ts.Identifier, isAdd: boolean = false): ts.ExpressionStatement {
|
||||
let textName: string;
|
||||
if (isAdd) {
|
||||
textName = `__${name.getText()}`;
|
||||
} else {
|
||||
textName = name.getText();
|
||||
}
|
||||
return ts.factory.createExpressionStatement(ts.factory.createBinaryExpression(
|
||||
createPropertyAccessExpressionWithThis(textName),
|
||||
createPropertyAccessExpressionWithThis(name.getText()),
|
||||
ts.factory.createToken(ts.SyntaxKind.EqualsToken),
|
||||
createPropertyAccessExpressionWithParams(name.getText())));
|
||||
}
|
||||
|
||||
@@ -29,10 +29,10 @@ struct CustomContainer {
|
||||
}
|
||||
}
|
||||
|
||||
@Builder function specificParam(label1: string, label2: string) {
|
||||
@Builder function specificParam() {
|
||||
Column() {
|
||||
Text(label1)
|
||||
Text(label2)
|
||||
Text("label1")
|
||||
Text("label2")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ struct CustomContainerUser {
|
||||
.width(50)
|
||||
Text("content2")
|
||||
}
|
||||
specificParam("content3", "content4")
|
||||
specificParam()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -68,32 +68,26 @@ exports.expectResult =
|
||||
if (params.footer !== undefined) {
|
||||
this.footer = params.footer;
|
||||
}
|
||||
this.__child = params.child;
|
||||
this.child = params.child;
|
||||
}
|
||||
aboutToBeDeleted() {
|
||||
this.__child.aboutToBeDeleted();
|
||||
SubscriberManager.Get().delete(this.id());
|
||||
}
|
||||
get child() {
|
||||
return this.__child.get();
|
||||
}
|
||||
set child(newValue) {
|
||||
this.__child.set(newValue);
|
||||
}
|
||||
render() {
|
||||
Column.create();
|
||||
Text.create(this.header);
|
||||
Text.pop();
|
||||
this.child();
|
||||
Text.create(this.footer);
|
||||
Text.pop();
|
||||
Column.pop();
|
||||
}
|
||||
}
|
||||
function specificParam(label1, label2) {
|
||||
function specificParam() {
|
||||
Column.create();
|
||||
Text.create(label1);
|
||||
Text.create("label1");
|
||||
Text.pop();
|
||||
Text.create(label2);
|
||||
Text.create("label2");
|
||||
Text.pop();
|
||||
Column.pop();
|
||||
}
|
||||
@@ -121,7 +115,7 @@ class CustomContainerUser extends View {
|
||||
Text.create("content2");
|
||||
Text.pop();
|
||||
Column.pop();
|
||||
specificParam("content3", "content4");
|
||||
specificParam();
|
||||
}
|
||||
}));
|
||||
}
|
||||
@@ -136,7 +130,7 @@ class CustomContainerUser extends View {
|
||||
Text.create("content2");
|
||||
Text.pop();
|
||||
Column.pop();
|
||||
specificParam("content3", "content4");
|
||||
specificParam();
|
||||
}
|
||||
});
|
||||
View.create(earlierCreatedChild_2);
|
||||
|
||||
@@ -18,11 +18,11 @@ exports.source = `
|
||||
struct CustomContainer {
|
||||
header: string = "";
|
||||
footer: string = "";
|
||||
@BuilderParam child1: () => any;
|
||||
@BuilderParam child: () => any;
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
this.child1()
|
||||
this.child()
|
||||
Text(this.header)
|
||||
Text(this.footer)
|
||||
}
|
||||
@@ -44,9 +44,8 @@ struct CustomContainerUser {
|
||||
CustomContainer({
|
||||
header: "Header",
|
||||
footer: "Footer",
|
||||
}){
|
||||
this.specificChild()
|
||||
}
|
||||
child: this.specificChild
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -66,20 +65,14 @@ exports.expectResult =
|
||||
if (params.footer !== undefined) {
|
||||
this.footer = params.footer;
|
||||
}
|
||||
this.__child1 = params.child1;
|
||||
this.child = params.child;
|
||||
}
|
||||
aboutToBeDeleted() {
|
||||
this.__child1.aboutToBeDeleted();
|
||||
SubscriberManager.Get().delete(this.id());
|
||||
}
|
||||
get child1() {
|
||||
return this.__child1.get();
|
||||
}
|
||||
set child1(newValue) {
|
||||
this.__child1.set(newValue);
|
||||
}
|
||||
render() {
|
||||
Column.create();
|
||||
this.child();
|
||||
Text.create(this.header);
|
||||
Text.pop();
|
||||
Text.create(this.footer);
|
||||
@@ -112,18 +105,14 @@ class CustomContainerUser extends View {
|
||||
View.create(new CustomContainer("2", this, {
|
||||
header: "Header",
|
||||
footer: "Footer",
|
||||
child1: () => {
|
||||
this.specificChild();
|
||||
}
|
||||
child: this.specificChild
|
||||
}));
|
||||
}
|
||||
else {
|
||||
earlierCreatedChild_2.updateWithValueParams({
|
||||
header: "Header",
|
||||
footer: "Footer",
|
||||
child1: () => {
|
||||
this.specificChild();
|
||||
}
|
||||
child: this.specificChild
|
||||
});
|
||||
View.create(earlierCreatedChild_2);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user