mirror of
https://github.com/openharmony/developtools_ace-ets2bundle.git
synced 2026-07-25 14:16:03 -04:00
@@ -37,7 +37,8 @@ import {
|
||||
BUILDER_ATTR_NAME,
|
||||
BUILDER_ATTR_BIND,
|
||||
COMPONENT_STYLES_DECORATOR,
|
||||
STYLES
|
||||
STYLES,
|
||||
CUSTOM_COMPONENT_EARLIER_CREATE_CHILD
|
||||
} from './pre_define';
|
||||
import {
|
||||
BUILDIN_STYLE_NAMES,
|
||||
@@ -211,6 +212,9 @@ function processBuildMember(node: ts.MethodDeclaration, context: ts.Transformati
|
||||
const buildNode: ts.MethodDeclaration = processComponentBuild(node, log);
|
||||
return ts.visitNode(buildNode, visitBuild);
|
||||
function visitBuild(node: ts.Node): ts.Node {
|
||||
if (isCustomComponentNode(node)) {
|
||||
return node;
|
||||
}
|
||||
if (isGeometryView(node)) {
|
||||
node = processGeometryView(node as ts.ExpressionStatement, log);
|
||||
}
|
||||
@@ -240,9 +244,7 @@ function validateBuilderFunctionNode(node: ts.PropertyAccessExpression | ts.Iden
|
||||
ts.isIdentifier(node) && CUSTOM_BUILDER_METHOD.has(node.escapedText.toString())) &&
|
||||
!((ts.isPropertyAccessExpression(node) && validateBuilderParam(node)) ||
|
||||
(ts.isIdentifier(node) && node.parent && ts.isPropertyAccessExpression(node.parent) &&
|
||||
validateBuilderParam(node.parent))) &&
|
||||
// @ts-ignore
|
||||
(!node.parent.arguments || (node.parent.arguments && !node.parent.arguments.length))) {
|
||||
validateBuilderParam(node.parent)))) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@@ -285,6 +287,22 @@ function getParsedBuilderAttrArgument(node: ts.PropertyAccessExpression | ts.Ide
|
||||
return newObjectNode;
|
||||
}
|
||||
|
||||
function isCustomComponentNode(node:ts.NewExpression | ts.ExpressionStatement): boolean {
|
||||
if ((ts.isNewExpression(node) && ts.isIdentifier(node.expression) && node.expression.escapedText
|
||||
&& componentCollection.customComponents.has(node.expression.escapedText.toString())) ||
|
||||
// @ts-ignore
|
||||
(ts.isExpressionStatement(node) && node.expression && node.expression.expression &&
|
||||
// @ts-ignore
|
||||
node.expression.expression.expression && node.expression.expression.expression.escapedText &&
|
||||
// @ts-ignore
|
||||
node.expression.expression.expression.escapedText.toString().startsWith(
|
||||
CUSTOM_COMPONENT_EARLIER_CREATE_CHILD))) {
|
||||
return true;
|
||||
}else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function isGeometryView(node: ts.Node): boolean {
|
||||
if (ts.isExpressionStatement(node) && ts.isCallExpression(node.expression)) {
|
||||
const call: ts.CallExpression = node.expression;
|
||||
|
||||
@@ -105,9 +105,9 @@ function validateCustomComponentPrams(node: ts.ExpressionStatement, name: string
|
||||
ts.isObjectLiteralExpression(nodeArguments[0])) {
|
||||
const nodeArgument: ts.ObjectLiteralExpression = nodeArguments[0] as ts.ObjectLiteralExpression;
|
||||
nodeArgument.properties.forEach(item => {
|
||||
if (item.name && node.name.escapedText) {
|
||||
if (item.name && item.name.escapedText) {
|
||||
// @ts-ignore
|
||||
curChildProps.add(node.name.escapedText.toString());
|
||||
curChildProps.add(item.name.escapedText.toString());
|
||||
}
|
||||
if (isThisProperty(item, propertySet)) {
|
||||
validateStateManagement(item, name, log);
|
||||
|
||||
@@ -132,14 +132,14 @@ class CustomContainerUser {
|
||||
View.create(new CustomContainer("2", this, {
|
||||
header: "Header",
|
||||
footer: "Footer",
|
||||
child: {build:this.specificChild.bind(this)}
|
||||
child: this.specificChild
|
||||
}));
|
||||
}
|
||||
else {
|
||||
earlierCreatedChild_2.updateWithValueParams({
|
||||
header: "Header",
|
||||
footer: "Footer",
|
||||
child: {build:this.specificChild.bind(this)}
|
||||
child: this.specificChild
|
||||
});
|
||||
View.create(earlierCreatedChild_2);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user