Merge branch 'master' of gitee.com:openharmony/developtools_ace-ets2bundle into pathexpect

Change-Id: Idadeafaa509233c2cd3f35ac7ae61edf5dc34ade
This commit is contained in:
yfwang6
2022-08-02 09:24:09 +08:00
2 changed files with 7 additions and 3 deletions
+3 -2
View File
@@ -284,6 +284,7 @@ function processComponentMethod(node: ts.MethodDeclaration, parentComponentName:
context: ts.TransformationContext, log: LogInfo[], buildCount: BuildCount): ts.MethodDeclaration {
let updateItem: ts.MethodDeclaration = node;
const name: string = node.name.getText();
const customBuilder: ts.Decorator[] = [];
if (name === COMPONENT_BUILD_FUNCTION) {
buildCount.count = buildCount.count + 1;
if (node.parameters.length) {
@@ -301,13 +302,13 @@ function processComponentMethod(node: ts.MethodDeclaration, parentComponentName:
updateItem = ts.factory.updateMethodDeclaration(node, node.decorators, node.modifiers,
node.asteriskToken, node.name, node.questionToken, node.typeParameters, node.parameters,
node.type, processComponentBlock(node.body, false, log, true));
} else if (hasDecorator(node, COMPONENT_BUILDER_DECORATOR)) {
} else if (hasDecorator(node, COMPONENT_BUILDER_DECORATOR, customBuilder)) {
CUSTOM_BUILDER_METHOD.add(name);
INNER_CUSTOM_BUILDER_METHOD.add(name)
node.parameters.push(ts.factory.createParameterDeclaration(undefined, undefined, undefined,
ts.factory.createIdentifier(COMPONENT_CONSTRUCTOR_PARENT), undefined, undefined,
ts.factory.createIdentifier(COMPONENT_IF_UNDEFINED)));
const builderNode: ts.MethodDeclaration = ts.factory.updateMethodDeclaration(node, undefined,
const builderNode: ts.MethodDeclaration = ts.factory.updateMethodDeclaration(node, customBuilder,
node.modifiers, node.asteriskToken, node.name, node.questionToken, node.typeParameters,
node.parameters, node.type, processComponentBlock(node.body, false, log, false, true));
updateItem = processBuildMember(builderNode, context, log);
+4 -1
View File
@@ -138,10 +138,13 @@ class ComponentInfo {
export const componentInfo: ComponentInfo = new ComponentInfo();
export function hasDecorator(node: ts.MethodDeclaration | ts.FunctionDeclaration |
ts.StructDeclaration | ts.ClassDeclaration, decortorName: string): boolean {
ts.StructDeclaration | ts.ClassDeclaration, decortorName: string, customBuilder?: ts.Decorator[]): boolean {
if (node.decorators && node.decorators.length) {
for (let i = 0; i < node.decorators.length; i++) {
if (node.decorators[i].getText().replace(/\(.*\)$/, '').trim() === decortorName) {
if (customBuilder) {
customBuilder.push(...node.decorators.slice(i + 1), ...node.decorators.slice(0, i));
}
return true;
}
}