diff --git a/compiler/src/process_component_class.ts b/compiler/src/process_component_class.ts index e76ec1a..f7222f7 100644 --- a/compiler/src/process_component_class.ts +++ b/compiler/src/process_component_class.ts @@ -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); diff --git a/compiler/src/utils.ts b/compiler/src/utils.ts index 75dc9fd..f9d2779 100644 --- a/compiler/src/utils.ts +++ b/compiler/src/utils.ts @@ -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; } }