• Home
  • Raw
  • Download

Lines Matching refs:ts

16 import ts from 'typescript';
171 export function processComponentBuild(node: ts.MethodDeclaration,
172 log: LogInfo[]): ts.MethodDeclaration {
173 let newNode: ts.MethodDeclaration;
174 let renderNode: ts.Identifier;
176 renderNode = ts.factory.createIdentifier(COMPONENT_RENDER_FUNCTION);
178 renderNode = ts.factory.createIdentifier(COMPONENT_INITIAl_RENDER_FUNCTION);
182 newNode = ts.factory.updateMethodDeclaration(node, node.decorators, node.modifiers,
186 newNode = ts.factory.updateMethodDeclaration(node, node.decorators, node.modifiers,
193 export function processComponentBlock(node: ts.Block, isLazy: boolean, log: LogInfo[],
195 …forEachParameters: ts.NodeArray<ts.ParameterDeclaration> = undefined, isGlobalBuilder: boolean = f…
196 const newStatements: ts.Statement[] = [];
204 newStatements.unshift(ts.factory.createExpressionStatement(
205 createFunction(ts.factory.createIdentifier(COMPONENT_TRANSITION_NAME),
206 ts.factory.createIdentifier(COMPONENT_CREATE_FUNCTION), null)));
208 newStatements.unshift(createComponentCreationStatement(ts.factory.createExpressionStatement(
209 createFunction(ts.factory.createIdentifier(COMPONENT_TRANSITION_NAME),
210ts.factory.createIdentifier(COMPONENT_POP_FUNCTION), null)), [ts.factory.createExpressionStatement(
211 createFunction(ts.factory.createIdentifier(COMPONENT_TRANSITION_NAME),
212ts.factory.createIdentifier(COMPONENT_CREATE_FUNCTION), null))], COMPONENT_TRANSITION_NAME, false,…
214 newStatements.push(ts.factory.createExpressionStatement(
215 createFunction(ts.factory.createIdentifier(COMPONENT_TRANSITION_NAME),
216 ts.factory.createIdentifier(COMPONENT_POP_FUNCTION), null)));
221 return ts.factory.updateBlock(node, newStatements);
224 function validateRootNode(node: ts.MethodDeclaration, log: LogInfo[]): boolean {
227 const statement: ts.Statement = node.body.statements[0];
228 if (ts.isIfStatement(statement) || validateFirstNode(statement)) {
244 function validateFirstNode(node: ts.Statement): boolean {
253 function validateContainerComponent(node: ts.Statement): boolean {
254 if (ts.isExpressionStatement(node) && node.expression &&
255 (ts.isEtsComponentExpression(node.expression) || ts.isCallExpression(node.expression))) {
281 arguments: ts.NodeArray<ts.Expression> | [],
282 node?: ts.Node
285 function validateEtsComponentNode(node: ts.CallExpression | ts.EtsComponentExpression, result?: Nam…
286 let childNode: ts.Node = node;
288 while (ts.isCallExpression(childNode) && childNode.expression &&
289 ts.isPropertyAccessExpression(childNode.expression) && childNode.expression.expression) {
292 if (ts.isEtsComponentExpression(childNode)) {
293 if (ts.isIdentifier(childNode.expression)) {
304 let sourceNode: ts.SourceFile;
306 export function processComponentChild(node: ts.Block | ts.SourceFile, newStatements: ts.Statement[],
309 …forEachParameters: ts.NodeArray<ts.ParameterDeclaration> = undefined, isGlobalBuilder: boolean = f…
313 const compilerOptions = ts.readConfigFile(
314 path.resolve(__dirname, '../tsconfig.json'), ts.sys.readFile).config.compilerOptions;
318 …sourceNode = ts.createSourceFile('', node.getText(), ts.ScriptTarget.Latest, true, ts.ScriptKind.E…
324 if (ts.isExpressionStatement(item)) {
332 const [etsExpression, idName]: [ts.EtsComponentExpression, ts.Expression] = constant
334 if (ts.isIdentifier(etsExpression.expression)) {
341 const idName: ts.Expression = checkIdInIf(item, savedParent);
344 … if (item.expression && ts.isEtsComponentExpression(item.expression) && item.expression.body) {
345 const expressionResult: ts.ExpressionStatement =
351 processCustomComponent(item as ts.ExpressionStatement, newStatements, log, name,
393 } else if (ts.isIfStatement(item)) {
395 } else if (!ts.isBlock(item)) {
414 export function transferBuilderCall(node: ts.ExpressionStatement, name: string,
415 isBuilder: boolean = false): ts.ExpressionStatement {
416 if (node.expression && ts.isCallExpression(node.expression) && node.expression.arguments &&
417 …node.expression.arguments.length === 1 && ts.isObjectLiteralExpression(node.expression.arguments[0…
418 return ts.factory.createExpressionStatement(ts.factory.createCallExpression(
419 ts.factory.createCallExpression(
420 ts.factory.createPropertyAccessExpression(
422 ts.factory.createIdentifier(BUILDER_ATTR_BIND)
425 [ts.factory.createThis()]
428 [ts.factory.createCallExpression(
429 ts.factory.createIdentifier(BUILDER_PARAM_PROXY),
432 ts.factory.createStringLiteral(name),
438 return ts.factory.createExpressionStatement(ts.factory.createCallExpression(
439 ts.factory.createCallExpression(
440 ts.factory.createPropertyAccessExpression(
442 ts.factory.createIdentifier(BUILDER_ATTR_BIND)
445 [ts.factory.createThis()]
453 function traverseBuilderParams(node: ts.ObjectLiteralExpression,
454 isBuilder: boolean): ts.ObjectLiteralExpression {
455 const properties: ts.ObjectLiteralElementLike[] = [];
458 if (ts.isPropertyAssignment(property) && property.initializer &&
459 ts.isPropertyAccessExpression(property.initializer) && property.initializer.expression &&
460 property.initializer.name && ts.isIdentifier(property.initializer.name)) {
462 if (!isBuilder && property.initializer.expression.kind === ts.SyntaxKind.ThisKeyword ||
463 isBuilder && ts.isIdentifier(property.initializer.expression) &&
467 properties.push(ts.factory.createPropertyAssignment(
469 ts.factory.createArrowFunction(
474 ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken),
480 properties.push(ts.factory.createPropertyAssignment(
482 ts.factory.createArrowFunction(
487 ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken),
494 return ts.factory.createObjectLiteralExpression(properties);
497 function addProperties(properties: ts.ObjectLiteralElementLike[], property: ts.ObjectLiteralElement…
499 properties.push(ts.factory.createPropertyAssignment(
501 ts.factory.createArrowFunction(
506 ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken),
507 ts.factory.createParenthesizedExpression(ts.factory.createConditionalExpression(
508 ts.factory.createElementAccessExpression(
509 isBuilder ? ts.factory.createIdentifier($$) : ts.factory.createThis(),
510 ts.factory.createStringLiteral('__' + name)
512 ts.factory.createToken(ts.SyntaxKind.QuestionToken),
513 ts.factory.createElementAccessExpression(
514 isBuilder ? ts.factory.createIdentifier($$) : ts.factory.createThis(),
515 ts.factory.createStringLiteral('__' + name)
517 ts.factory.createToken(ts.SyntaxKind.ColonToken),
518 ts.factory.createElementAccessExpression(
519 isBuilder ? ts.factory.createIdentifier($$) : ts.factory.createThis(),
520 ts.factory.createStringLiteral(name)
527 function addInnerBuilderParameter(node: ts.ExpressionStatement,
528 isGlobalBuilder: boolean = false): ts.ExpressionStatement {
529 if (node.expression && ts.isCallExpression(node.expression) && node.expression.arguments) {
530 …node.expression.arguments.push(isGlobalBuilder ? parentConditionalExpression() : ts.factory.create…
531 return ts.factory.createExpressionStatement(ts.factory.updateCallExpression(node.expression,
538 function processExpressionStatementChange(node: ts.ExpressionStatement, nextNode: ts.Block,
539 log: LogInfo[]): ts.ExpressionStatement {
542 if (node.expression.expression && ts.isIdentifier(node.expression.expression)) {
559 function processBlockToExpression(node: ts.ExpressionStatement, nextNode: ts.Block,
560 log: LogInfo[], name: string): ts.ExpressionStatement {
562 const newBlock: ts.Block = processComponentBlock(nextNode, false, log);
563 const arrowNode: ts.ArrowFunction = ts.factory.createArrowFunction(undefined, undefined,
564 [], undefined, ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), newBlock);
565 const newPropertyAssignment:ts.PropertyAssignment = ts.factory.createPropertyAssignment(
566 ts.factory.createIdentifier(childParam), arrowNode);
568 let argumentsArray: ts.ObjectLiteralExpression[] = node.expression.arguments;
570 argumentsArray = [ts.factory.createObjectLiteralExpression([newPropertyAssignment], true)];
572 argumentsArray = [ts.factory.createObjectLiteralExpression(
576 const callNode: ts.CallExpression = ts.factory.updateCallExpression(
584 node = ts.factory.updateExpressionStatement(node, callNode);
589 etsComponentNode: ts.EtsComponentExpression;
592 function parseEtsComponentExpression(node: ts.ExpressionStatement): EtsComponentResult {
593 let etsComponentNode: ts.EtsComponentExpression;
597 if (ts.isCallExpression(temp) && temp.expression &&
598 ts.isPropertyAccessExpression(temp.expression)) {
601 if (ts.isEtsComponentExpression(temp)) {
610 function processInnerComponent(node: ts.ExpressionStatement, innerCompStatements: ts.Statement[],
612 isTransition: boolean = false, idName: ts.Expression = undefined): void {
613 const newStatements: ts.Statement[] = [];
617 validateEtsComponentNode(node.expression as ts.EtsComponentExpression, nameResult);
628 function processNormalComponent(node: ts.ExpressionStatement, nameResult: NameResult,
629 …innerCompStatements: ts.Statement[], log: LogInfo[], parent: string = undefined, isBuilder:boolean…
630 …isGlobalBuilder: boolean = false, isTransition: boolean = false, idName: ts.Expression = undefined…
631 const newStatements: ts.Statement[] = [];
632 const immutableStatements: ts.Statement[] = [];
642 …if (etsComponentResult.etsComponentNode.body && ts.isBlock(etsComponentResult.etsComponentNode.bod…
672 export function ifRetakeId(blockContent: ts.Statement[], idName: ts.Expression): ts.IfStatement {
673 return ts.factory.createIfStatement(
674 ts.factory.createPrefixUnaryExpression(
675 ts.SyntaxKind.ExclamationToken,
676 ts.factory.createCallExpression(
677 ts.factory.createPropertyAccessExpression(
678 ts.factory.createIdentifier(COMPONENT_IF),
679 ts.factory.createIdentifier(CAN_RETAKE)
685 ts.factory.createBlock(
693 function processDebug(node: ts.Statement, nameResult: NameResult, newStatements: ts.Statement[],
694 getNode: boolean = false): ts.ExpressionStatement {
696 let posOfNode: ts.LineAndCharacter;
719 const debugNode: ts.ExpressionStatement = ts.factory.createExpressionStatement(
720 createFunction(ts.factory.createIdentifier(nameResult.name),
721 ts.factory.createIdentifier(COMPONENT_DEBUGLINE_FUNCTION),
722 ts.factory.createNodeArray([ts.factory.createStringLiteral(debugInfo)])));
730 function processInnerCompStatements(innerCompStatements: ts.Statement[],
731 …newStatements: ts.Statement[], node: ts.Statement, isGlobalBuilder: boolean, isTransition: boolean,
732 nameResult: NameResult, immutableStatements: ts.Statement[], componentName: string): void {
741 export function createComponentCreationStatement(node: ts.Statement, innerStatements: ts.Statement[…
743 nameResult: NameResult = undefined, immutableStatements: ts.Statement[] = null): ts.Statement {
744 const blockArr: ts.Statement[] = [...innerStatements];
755 const creationArgs: ts.Expression[] = [
756 ts.factory.createArrowFunction(undefined, undefined,
758 ts.factory.createParameterDeclaration(undefined, undefined, undefined,
759 ts.factory.createIdentifier(ELMTID), undefined, undefined, undefined),
760 ts.factory.createParameterDeclaration(undefined, undefined, undefined,
761 ts.factory.createIdentifier(ISINITIALRENDER), undefined, undefined, undefined)
763 ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken),
764 ts.factory.createBlock(blockArr, true)
768 creationArgs.push(isTransition ? ts.factory.createNull() :
769 ts.factory.createIdentifier(componentName));
771 return ts.factory.createExpressionStatement(
772 ts.factory.createCallExpression(
773 ts.factory.createPropertyAccessExpression(createConditionParent(isGlobalBuilder),
774 ts.factory.createIdentifier(partialUpdateConfig.optimizeComponent ?
780 export function createViewStackProcessorStatement(propertyAccessName: string, elmtId?: string): ts.…
781 return ts.factory.createExpressionStatement(
782 ts.factory.createCallExpression(
783 ts.factory.createPropertyAccessExpression(
784 ts.factory.createIdentifier(VIEWSTACKPROCESSOR),
785 ts.factory.createIdentifier(propertyAccessName)
788 elmtId ? [ts.factory.createIdentifier(ELMTID)] : []
793 function createInitRenderStatement(node: ts.Statement,
794 immutableStatements: ts.Statement[], blockArr: ts.Statement[]): void {
797 blockArr.push(ts.factory.createIfStatement(
798 ts.factory.createIdentifier(ISINITIALRENDER),
799 ts.factory.createBlock(immutableStatements, true)
803 blockArr.push(ts.factory.createIfStatement(
804 ts.factory.createPrefixUnaryExpression(
805 ts.SyntaxKind.ExclamationToken,
806 ts.factory.createIdentifier(ISINITIALRENDER)
808 ts.factory.createBlock(
810 ts.isExpressionStatement(node) ?
816 ts.factory.createBlock(immutableStatements, true) : undefined
821 function processItemComponent(node: ts.ExpressionStatement, nameResult: NameResult, innerCompStatem…
822 log: LogInfo[], isGlobalBuilder: boolean = false, idName: ts.Expression = undefined): void {
823 const itemRenderInnerStatements: ts.Statement[] = [];
824 const immutableStatements: ts.Statement[] = [];
825 const deepItemRenderInnerStatements: ts.Statement[] = [];
828 const itemCreateStatement: ts.Statement = createItemCreate(nameResult, isLazyCreate);
831 …if (etsComponentResult.etsComponentNode.body && ts.isBlock(etsComponentResult.etsComponentNode.bod…
840 let generateItem: ts.IfStatement | ts.Block;
853 function createItemCreate(nameResult: NameResult, isLazyCreate: boolean): ts.Statement {
854 const itemCreateArgs: ts.Expression[] = [];
856 itemCreateArgs.push(ts.factory.createIdentifier(DEEPRENDERFUNCTION), ts.factory.createTrue());
859 ts.factory.createArrowFunction(undefined, undefined, [], undefined,
860 ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken),
861 ts.factory.createBlock([], false)),
862 ts.factory.createFalse()
866 return ts.factory.createExpressionStatement(ts.factory.createCallExpression(
867 ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier(nameResult.name),
868 ts.factory.createIdentifier(COMPONENT_CREATE_FUNCTION)), undefined, itemCreateArgs));
872 node: ts.ExpressionStatement,
873 itemRenderInnerStatements: ts.Statement[],
874 deepItemRenderInnerStatements: ts.Statement[],
876 immutableStatements: ts.Statement[]
877 ): ts.Block {
878 const blockNode: ts.Statement[] = [
884 ts.factory.createExpressionStatement(ts.factory.createCallExpression(
885 ts.factory.createPropertyAccessExpression(
886 ts.factory.createThis(),
887 ts.factory.createIdentifier(OBSERVECOMPONENTCREATION)
890 [ts.factory.createIdentifier(ITEMCREATION)]
897 ts.factory.createExpressionStatement(ts.factory.createCallExpression(
898 ts.factory.createIdentifier(OBSERVEDDEEPRENDER), undefined, []))
901 return ts.factory.createBlock(blockNode, true);
904 function checkLazyCreate(node: ts.ExpressionStatement, nameResult: NameResult): boolean {
906 if (nameResult.arguments.length && ts.isStringLiteral(nameResult.arguments[0]) &&
919 node: ts.ExpressionStatement,
920 itemRenderInnerStatements: ts.Statement[],
922 immutableStatements: ts.Statement[]
923 ): ts.VariableStatement {
924 return ts.factory.createVariableStatement(
926 ts.factory.createVariableDeclarationList(
927 [ts.factory.createVariableDeclaration(
928 ts.factory.createIdentifier(ITEMCREATION), undefined, undefined,
929 ts.factory.createArrowFunction(undefined, undefined,
931 ts.factory.createParameterDeclaration(undefined, undefined, undefined,
932 ts.factory.createIdentifier(ELMTID), undefined, undefined, undefined),
933 ts.factory.createParameterDeclaration(undefined, undefined, undefined,
934 ts.factory.createIdentifier(ISINITIALRENDER), undefined, undefined, undefined)
936 ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken),
937 ts.factory.createBlock(
942 ts.factory.createIfStatement(
943 ts.factory.createPrefixUnaryExpression(
944 ts.SyntaxKind.ExclamationToken,
945 ts.factory.createIdentifier(ISINITIALRENDER)
947 ts.factory.createBlock(
952 ts.factory.createBlock(immutableStatements, true) : undefined
960 ts.NodeFlags.Const
966 node: ts.ExpressionStatement,
967 deepItemRenderInnerStatements: ts.Statement[]
968 ): ts.VariableStatement {
969 return ts.factory.createVariableStatement(
971 ts.factory.createVariableDeclarationList(
972 [ts.factory.createVariableDeclaration(
973 ts.factory.createIdentifier(DEEPRENDERFUNCTION), undefined, undefined,
974 ts.factory.createArrowFunction(undefined, undefined,
976 ts.factory.createParameterDeclaration(undefined, undefined, undefined,
977 ts.factory.createIdentifier(ELMTID), undefined, undefined, undefined),
978 ts.factory.createParameterDeclaration(undefined, undefined, undefined,
979 ts.factory.createIdentifier(ISINITIALRENDER), undefined, undefined, undefined)
981 ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken),
982 ts.factory.createBlock(
984 ts.factory.createExpressionStatement(ts.factory.createCallExpression(
985 ts.factory.createIdentifier(ITEMCREATION), undefined,
987 ts.factory.createIdentifier(ELMTID),
988 ts.factory.createIdentifier(ISINITIALRENDER)
991 ts.factory.createExpressionStatement(ts.factory.createCallExpression(
992 ts.factory.createPropertyAccessExpression(
993 ts.factory.createPropertyAccessExpression(
994 ts.factory.createThis(),
995 ts.factory.createIdentifier(UPDATE_FUNC_BY_ELMT_ID)
997 ts.factory.createIdentifier(CREATE_SET_METHOD)
999 [ts.factory.createIdentifier(ELMTID), ts.factory.createIdentifier(ITEMCREATION)]
1008 ts.NodeFlags.Const
1014 node: ts.ExpressionStatement,
1015 deepItemRenderInnerStatements: ts.Statement[]
1016 ): ts.VariableStatement {
1017 return ts.factory.createVariableStatement(
1019 ts.factory.createVariableDeclarationList(
1020 [ts.factory.createVariableDeclaration(
1021 ts.factory.createIdentifier(OBSERVEDDEEPRENDER),
1024 ts.factory.createArrowFunction(
1029 ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken),
1030 ts.factory.createBlock(
1032 ts.factory.createExpressionStatement(ts.factory.createCallExpression(
1033 ts.factory.createPropertyAccessExpression(
1034 ts.factory.createThis(),
1035 ts.factory.createIdentifier(OBSERVECOMPONENTCREATION)
1038 [ts.factory.createIdentifier(ITEMCREATION)]
1047 ts.NodeFlags.Const
1052 function processTabAndNav(node: ts.ExpressionStatement, innerCompStatements: ts.Statement[],
1053 …nameResult: NameResult, log: LogInfo[], isGlobalBuilder: boolean = false, idName: ts.Expression = …
1055 const TabContentComp: ts.EtsComponentExpression = getEtsComponentExpression(node);
1056 const TabContentBody: ts.Block = TabContentComp.body;
1057 let tabContentCreation: ts.Statement;
1058 …const tabContentPop: ts.Statement = ts.factory.createExpressionStatement(ts.factory.createCallExpr…
1059 ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier(name),
1060 ts.factory.createIdentifier(COMPONENT_POP_FUNCTION)), undefined, []));
1061 const tabAttrs: ts.Statement[] = [];
1062 const immutableStatements: ts.Statement[] = [];
1068 const newTabContentChildren: ts.Statement[] = [];
1070 tabContentCreation = ts.factory.createExpressionStatement(
1071 ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(
1072 ts.factory.createIdentifier(name), ts.factory.createIdentifier(COMPONENT_CREATE_FUNCTION)),
1073 undefined, [ts.factory.createArrowFunction(undefined, undefined, [], undefined,
1074 ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken),
1075 ts.factory.createBlock([...newTabContentChildren], true))]));
1076 …bindComponentAttr(node, ts.factory.createIdentifier(name), tabAttrs, log, true, false, immutableSt…
1081 tabContentCreation = ts.factory.createExpressionStatement(ts.factory.createCallExpression(
1082 ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier(name),
1083 ts.factory.createIdentifier(COMPONENT_CREATE_FUNCTION)), undefined, []));
1084 …bindComponentAttr(node, ts.factory.createIdentifier(name), tabAttrs, log, true, false, immutableSt…
1096 function getRealNodePos(node: ts.Node): number {
1106 function processForEachComponent(node: ts.ExpressionStatement, newStatements: ts.Statement[],
1108 const popNode: ts.ExpressionStatement = ts.factory.createExpressionStatement(createFunction(
1110 node.expression.expression as ts.Identifier,
1111 ts.factory.createIdentifier(COMPONENT_POP_FUNCTION), null));
1112 if (ts.isCallExpression(node.expression)) {
1113 const propertyNode: ts.PropertyAccessExpression = ts.factory.createPropertyAccessExpression(
1114 node.expression.expression as ts.Identifier,
1115 ts.factory.createIdentifier(COMPONENT_CREATE_FUNCTION)
1117 const argumentsArray: ts.Expression[] = Array.from(node.expression.arguments);
1118 let arrayObserveredObject: ts.CallExpression;
1120 arrayObserveredObject = ts.factory.createCallExpression(
1121ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier(FOREACH_OBSERVED_OBJECT),
1122 ts.factory.createIdentifier(FOREACH_GET_RAW_OBJECT)), undefined, [argumentsArray[0]]);
1125 const newArrowNode: ts.ArrowFunction =
1126 processForEachBlock(node.expression, log, isBuilder) as ts.ArrowFunction;
1130 node = addForEachId(ts.factory.updateExpressionStatement(node, ts.factory.updateCallExpression(
1136 function processForEachComponentNew(node: ts.ExpressionStatement, newStatements: ts.Statement[],
1138 const newForEachStatements: ts.Statement[] = [];
1139 const popNode: ts.ExpressionStatement = ts.factory.createExpressionStatement(createFunction(
1140 (node.expression as ts.CallExpression).expression as ts.Identifier,
1141 ts.factory.createIdentifier(COMPONENT_POP_FUNCTION), null));
1142 if (ts.isCallExpression(node.expression)) {
1143 const argumentsArray: ts.Expression[] = Array.from(node.expression.arguments);
1144 const propertyNode: ts.ExpressionStatement = ts.factory.createExpressionStatement(
1145 ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(
1146 node.expression.expression as ts.Identifier,
1147 ts.factory.createIdentifier(COMPONENT_CREATE_FUNCTION)), undefined, []));
1148 const newArrowNode: ts.NodeArray<ts.Statement> =
1149 … processForEachBlock(node.expression, log, false, isGlobalBuilder) as ts.NodeArray<ts.Statement>;
1150 …const itemGenFunctionStatement: ts.VariableStatement = createItemGenFunctionStatement(node.express…
1152 …const itemIdFuncStatement: ts.VariableStatement = createItemIdFuncStatement(node.expression, argum…
1153 …const updateFunctionStatement: ts.ExpressionStatement = createUpdateFunctionStatement(argumentsArr…
1154 const lazyForEachStatement: ts.ExpressionStatement = createLazyForEachStatement(argumentsArray);
1160 …newStatements.push(ts.factory.createBlock([itemGenFunctionStatement, itemIdFuncStatement, lazyForE…
1163 …newStatements.push(ts.factory.createBlock([itemGenFunctionStatement, lazyForEachStatement, popNode…
1170 node: ts.CallExpression,
1171 argumentsArray: ts.Expression[],
1172 newArrowNode: ts.NodeArray<ts.Statement>
1173 ): ts.VariableStatement {
1174 if (argumentsArray[1] && ts.isArrowFunction(argumentsArray[1])) {
1175 return ts.factory.createVariableStatement(
1177 ts.factory.createVariableDeclarationList(
1178 [ts.factory.createVariableDeclaration(
1179 ts.factory.createIdentifier(node.expression.getText() === COMPONENT_FOREACH ?
1182 ts.factory.createArrowFunction(
1186 undefined, ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken),
1187 ts.factory.createBlock(
1196 ts.NodeFlags.Const
1202 … isForEachItemGeneratorParam(argumentsArray: ts.Expression[], newArrowNode: ts.NodeArray<ts.Statem…
1204 ts.factory.createVariableStatement(
1206 ts.factory.createVariableDeclarationList(
1207 [ts.factory.createVariableDeclaration(
1208 ts.factory.createIdentifier(
1212 ts.factory.createIdentifier(_ITEM)
1214 ts.NodeFlags.Const
1221 function getParameters(node: ts.ArrowFunction): ts.ParameterDeclaration[] {
1222 const parameterArr: ts.ParameterDeclaration[] = [
1223 ts.factory.createParameterDeclaration(
1224 undefined, undefined, undefined, ts.factory.createIdentifier(_ITEM))
1233 node: ts.CallExpression,
1234 argumentsArray: ts.Expression[]
1235 ): ts.VariableStatement {
1236 if (argumentsArray[2] && ts.isArrowFunction(argumentsArray[2])) {
1237 return ts.factory.createVariableStatement(
1239 ts.factory.createVariableDeclarationList(
1240 [ts.factory.createVariableDeclaration(
1241 ts.factory.createIdentifier(node.expression.getText() === COMPONENT_FOREACH ?
1245 ts.NodeFlags.Const
1251 function createUpdateFunctionStatement(argumentsArray: ts.Expression[],
1252 isGlobalBuilder: boolean = false): ts.ExpressionStatement {
1253 return ts.factory.createExpressionStatement(
1254 ts.factory.createCallExpression(
1255 ts.factory.createPropertyAccessExpression(
1256 isGlobalBuilder ? parentConditionalExpression() : ts.factory.createThis(),
1257 ts.factory.createIdentifier(FOREACHUPDATEFUNCTION)
1265 function addForEachIdFuncParameter(argumentsArray: ts.Expression[]): ts.Expression[] {
1266 const addForEachIdFuncParameterArr: ts.Expression[] = [];
1268 ts.factory.createIdentifier(ELMTID),
1270 ts.factory.createIdentifier(FOREACHITEMGENFUNCTION)
1275 …addForEachIdFuncParameterArr.push(...addForEachParameter(ts.factory.createIdentifier(COMPONENT_IF_…
1293 …n addForEachParameter(forEachItemIdContent: ts.Expression, forEachItemGen: string, forEachItemId: …
1294 return [forEachItemIdContent, ts.factory.createIdentifier(forEachItemGen),
1295 ts.factory.createIdentifier(forEachItemId)];
1298 function createLazyForEachStatement(argumentsArray: ts.Expression[]): ts.ExpressionStatement {
1299 const parameterList: ts.Expression[] = [
1300 ts.factory.createStringLiteral(componentInfo.id.toString()),
1301 ts.factory.createThis(),
1303 ts.factory.createIdentifier(__LAZYFOREACHITEMGENFUNCTION)
1306 parameterList.push(ts.factory.createIdentifier(__LAZYFOREACHITEMIDFUNC));
1308 return ts.factory.createExpressionStatement(
1309 ts.factory.createCallExpression(
1310 ts.factory.createPropertyAccessExpression(
1311 ts.factory.createIdentifier(COMPONENT_LAZYFOREACH),
1312 ts.factory.createIdentifier(COMPONENT_CREATE_FUNCTION)
1320 function addForEachId(node: ts.ExpressionStatement, isGlobalBuilder: boolean = false): ts.Expressio…
1321 const forEachComponent: ts.CallExpression = node.expression as ts.CallExpression;
1322 return ts.factory.updateExpressionStatement(node, ts.factory.updateCallExpression(
1324 [ts.factory.createStringLiteral((++componentInfo.id).toString()),
1325 isGlobalBuilder ? parentConditionalExpression() : ts.factory.createThis(),
1329 export function parentConditionalExpression(): ts.ConditionalExpression {
1330 return ts.factory.createConditionalExpression(
1331 ts.factory.createIdentifier(COMPONENT_CONSTRUCTOR_PARENT),
1332 ts.factory.createToken(ts.SyntaxKind.QuestionToken),
1333 ts.factory.createIdentifier(COMPONENT_CONSTRUCTOR_PARENT),
1334 ts.factory.createToken(ts.SyntaxKind.ColonToken),
1335 ts.factory.createThis());
1338 function processForEachBlock(node: ts.CallExpression, log: LogInfo[],
1339 …isBuilder: boolean = false, isGlobalBuilder: boolean = false): ts.NodeArray<ts.Statement> | ts.Arr…
1340 if (node.arguments.length > 1 && ts.isArrowFunction(node.arguments[1])) {
1342 const arrowNode: ts.ArrowFunction = node.arguments[1] as ts.ArrowFunction;
1343 const body: ts.ConciseBody = arrowNode.body;
1344 if (node.arguments.length > 2 && !ts.isArrowFunction(node.arguments[2])) {
1350 } else if (!ts.isBlock(body)) {
1351 const statement: ts.Statement = ts.factory.createExpressionStatement(body);
1352 const blockNode: ts.Block = ts.factory.createBlock([statement], true);
1356 return ts.factory.updateArrowFunction(
1366 return ts.factory.updateArrowFunction(
1378 function createRenderingInProgress(isTrue: boolean): ts.ExpressionStatement {
1379 return ts.factory.createExpressionStatement(ts.factory.createBinaryExpression(
1380 ts.factory.createPropertyAccessExpression(
1381 ts.factory.createThis(),
1382 ts.factory.createIdentifier(IS_RENDERING_IN_PROGRESS)
1384 ts.factory.createToken(ts.SyntaxKind.EqualsToken),
1385 isTrue ? ts.factory.createTrue() : ts.factory.createFalse()
1389 function processIfStatement(node: ts.IfStatement, newStatements: ts.Statement[],
1391 const ifCreate: ts.ExpressionStatement = createIfCreate();
1392 …const newIfNode: ts.IfStatement = processInnerIfStatement(node, 0, log, isBuilder, isGlobalBuilder…
1393 const ifPop: ts.ExpressionStatement = createIfPop();
1401 function processInnerIfStatement(node: ts.IfStatement, id: number, log: LogInfo[],
1402 isBuilder: boolean = false, isGlobalBuilder: boolean = false): ts.IfStatement {
1403 if (ts.isIdentifier(node.expression) && node.expression.originalKeywordKind === undefined &&
1410 node = ts.factory.updateIfStatement(node, ts.factory.createIdentifier(COMPONENT_IF_UNDEFINED),
1413 …const newThenStatement: ts.Statement = processThenStatement(node.thenStatement, id, log, isBuilder…
1414 …const newElseStatement: ts.Statement = processElseStatement(node.elseStatement, id, log, isBuilder…
1415 const newIfNode: ts.IfStatement = ts.factory.updateIfStatement(
1420 function processThenStatement(thenStatement: ts.Statement, id: number,
1421 log: LogInfo[], isBuilder: boolean = false, isGlobalBuilder: boolean = false): ts.Statement {
1422 if (ts.isExpressionStatement(thenStatement) && ts.isIdentifier(thenStatement.expression) &&
1432 if (ts.isBlock(thenStatement)) {
1434 } else if (ts.isIfStatement(thenStatement)) {
1436 thenStatement = ts.factory.createBlock(
1443 thenStatement = ts.factory.createBlock([thenStatement], true);
1444 … thenStatement = processIfBlock(thenStatement as ts.Block, id, log, isBuilder, isGlobalBuilder);
1450 function processElseStatement(elseStatement: ts.Statement, id: number,
1451 log: LogInfo[], isBuilder: boolean = false, isGlobalBuilder: boolean = false): ts.Statement {
1453 if (ts.isBlock(elseStatement)) {
1455 } else if (ts.isIfStatement(elseStatement)) {
1458 elseStatement = ts.factory.createBlock([elseStatement], true);
1459 …elseStatement = processIfBlock(elseStatement as ts.Block, id + 1, log, isBuilder, isGlobalBuilder);
1462 elseStatement = ts.factory.createBlock([
1463 ts.factory.createExpressionStatement(ts.factory.createCallExpression(
1464 ts.factory.createPropertyAccessExpression(
1465 ts.factory.createThis(),
1466 ts.factory.createIdentifier(IFELSEBRANCHUPDATEFUNCTION)
1470 ts.factory.createNumericLiteral(++id),
1471 ts.factory.createArrowFunction(
1476 ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken),
1477 ts.factory.createBlock(
1489 function processIfBlock(block: ts.Block, id: number, log: LogInfo[], isBuilder: boolean = false,
1490 isGlobalBuilder: boolean = false): ts.Block {
1495 function addIfBranchId(id: number, isGlobalBuilder: boolean = false, container: ts.Block): ts.Block…
1496 let containerStatements: ts.Statement[];
1502 return ts.factory.updateBlock(container, containerStatements);
1505 function createIf(): ts.Identifier {
1506 return ts.factory.createIdentifier(COMPONENT_IF);
1509 function createIfCreate(): ts.ExpressionStatement {
1510 return ts.factory.createExpressionStatement(createFunction(createIf(),
1511 ts.factory.createIdentifier(COMPONENT_CREATE_FUNCTION), ts.factory.createNodeArray([])));
1514 function createIfPop(): ts.ExpressionStatement {
1515 return ts.factory.createExpressionStatement(createFunction(createIf(),
1516 ts.factory.createIdentifier(COMPONENT_POP_FUNCTION), null));
1519 function createIfBranchId(id: number): ts.ExpressionStatement {
1520 return ts.factory.createExpressionStatement(createFunction(createIf(),
1521 ts.factory.createIdentifier(COMPONENT_IF_BRANCH_ID_FUNCTION),
1522 ts.factory.createNodeArray([ts.factory.createNumericLiteral(id)])));
1525 function createIfBranchFunc(id: number, innerStatements: ts.Statement[],
1526 isGlobalBuilder: boolean = false): ts.ExpressionStatement {
1527 …return ts.factory.createExpressionStatement(ts.factory.createCallExpression(ts.factory.createPrope…
1528 isGlobalBuilder ? parentConditionalExpression() : ts.factory.createThis(),
1529 ts.factory.createIdentifier(IFELSEBRANCHUPDATEFUNCTION)), undefined,
1530 …[ts.factory.createNumericLiteral(id), ts.factory.createArrowFunction(undefined, undefined, [], und…
1531ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), ts.factory.createBlock(innerStatemen…
1535 newNode: ts.ExpressionStatement;
1536 identifierNode: ts.Identifier;
1542 function createComponent(node: ts.ExpressionStatement, type: string): CreateResult {
1550 let identifierNode: ts.Identifier = ts.factory.createIdentifier(type);
1552 while (temp && !ts.isIdentifier(temp) && temp.expression) {
1555 if (temp && temp.parent && (ts.isCallExpression(temp.parent) ||
1556 ts.isEtsComponentExpression(temp.parent)) && ts.isIdentifier(temp)) {
1560 ? ts.factory.createIdentifier(COMPONENT_CREATE_CHILD_FUNCTION)
1561 : ts.factory.createIdentifier(COMPONENT_CREATE_LABEL_FUNCTION);
1570 ? ts.factory.createExpressionStatement(createFunction(temp, identifierNode, null))
1571 …: ts.factory.createExpressionStatement(createFunction(temp, identifierNode, checkArguments(temp, t…
1577 function checkArguments(temp: ts.Identifier, type: string): ts.Expression[] {
1578 const newArguments: ts.Expression[] = [];
1581 if (ts.isConditionalExpression(argument)) {
1595 ts.factory.createStringLiteral(`${projectConfig.bundleName}/${projectConfig.moduleName}`)
1599 function checkContainer(name: string, node: ts.Node): boolean {
1602 ts.isObjectLiteralExpression(node.arguments[0]) && node.arguments[0].properties &&
1606 function checkComponentType(properties: ts.PropertyAssignment[]): boolean {
1616 function isXComponentContainer(item: ts.PropertyAssignment): boolean {
1617 return item.name && ts.isIdentifier(item.name) && item.name.getText() === RESOURCE_NAME_TYPE &&
1618 item.initializer && ((ts.isStringLiteral(item.initializer) &&
1623 (ts.isNumericLiteral(item.initializer) && item.initializer.getText() === '1') ||
1625 (ts.isPropertyAccessExpression(item.initializer) && item.initializer.expression &&
1626 ts.isIdentifier(item.initializer.expression) && item.initializer.name &&
1627ts.isIdentifier(item.initializer.name) && item.initializer.expression.getText() === XCOMPONENTTYPE…
1632 statement: ts.Statement,
1638 reuseId: ts.Node
1641 export function bindComponentAttr(node: ts.ExpressionStatement, identifierNode: ts.Identifier,
1642 newStatements: ts.Statement[], log: LogInfo[], reverse: boolean = true,
1643 isStylesAttr: boolean = false, newImmutableStatements: ts.Statement[] = null,
1646 const statements: ts.Statement[] = [];
1647 const immutableStatements: ts.Statement[] = [];
1648 const updateStatements: ts.Statement[] = [];
1655 if (ts.isPropertyAccessExpression(temp)) {
1662 while (temp && ts.isCallExpression(temp) && temp.expression) {
1667 if (ts.isIdentifier(temp.expression)) {
1669 } else if (ts.isPropertyAccessExpression(temp.expression)) {
1684 if (ts.isPropertyAccessExpression(temp.expression) &&
1685 temp.expression.name && ts.isIdentifier(temp.expression.name) &&
1693 } else if (ts.isIdentifier(temp.expression)) {
1725 function parseRecycleId(node: ts.CallExpression, attr: ts.Identifier, isRecycleComponent: boolean,
1732 function processCustomBuilderProperty(node: ts.CallExpression, identifierNode: ts.Identifier,
1733 propertyName: string): ts.CallExpression {
1734 const newArguments: ts.Expression[] = [];
1735 node.arguments.forEach((argument: ts.Expression | ts.Identifier, index: number) => {
1736 if (ts.isConditionalExpression(argument)) {
1744 node = ts.factory.updateCallExpression(node, node.expression, node.typeArguments, newArguments);
1748 function isBuilderChangeNode(argument: ts.Node, identifierNode: ts.Identifier, propertyName: string…
1749 return ts.isPropertyAccessExpression(argument) && argument.name && ts.isIdentifier(argument.name)
1751 ts.isCallExpression(argument) && argument.expression && argument.expression.name &&
1752 ts.isIdentifier(argument.expression.name) &&
1753 CUSTOM_BUILDER_METHOD.has(argument.expression.name.getText()) || ts.isIdentifier(argument) &&
1755ts.isObjectLiteralExpression(argument) && BIND_OBJECT_PROPERTY.get(identifierNode.escapedText.toSt…
1757 ts.isCallExpression(argument) && argument.expression && ts.isIdentifier(argument.expression) &&
1761 function parseBuilderNode(node: ts.Node, propertyName: string):
1762 ts.ObjectLiteralExpression | ts.CallExpression | ts.ArrowFunction {
1765 return processPropertyBuilderWithoutKey(node as ts.PropertyAccessExpression);
1767 return processPropertyBuilder(node as ts.PropertyAccessExpression);
1769 } else if (ts.isIdentifier(node) && CUSTOM_BUILDER_METHOD.has(node.escapedText.toString())) {
1775 } else if (ts.isCallExpression(node)) {
1781 } else if (ts.isObjectLiteralExpression(node)) {
1786 export function processObjectPropertyBuilder(node: ts.ObjectLiteralExpression): ts.ObjectLiteralExp…
1787 const newProperties: ts.PropertyAssignment[] = [];
1788 node.properties.forEach((property: ts.PropertyAssignment) => {
1789 if (property.name && ts.isIdentifier(property.name) &&
1792 …if (isPropertyAccessExpressionNode(property.initializer) || ts.isIdentifier(property.initializer) …
1794 newProperties.push(ts.factory.updatePropertyAssignment(property, property.name,
1795 ts.factory.createCallExpression(
1796 ts.factory.createPropertyAccessExpression(
1798 ts.factory.createIdentifier(BUILDER_ATTR_BIND)
1801 [ts.factory.createThis()]
1806 } else if (ts.isObjectLiteralExpression(property.initializer)) {
1807 newProperties.push(ts.factory.updatePropertyAssignment(property, property.name,
1816 return ts.factory.updateObjectLiteralExpression(node, newProperties);
1819 function transformBuilderCallExpression(property: ts.PropertyAssignment): ts.PropertyAssignment {
1820 return ts.factory.updatePropertyAssignment(property, property.name,
1821 ts.factory.createCallExpression(
1822 ts.factory.createPropertyAccessExpression(
1824 ts.factory.createIdentifier(BUILDER_ATTR_BIND)
1827 [ts.factory.createThis(), ...(property.initializer.arguments || [])]
1831 function isInnerBuilderCallExpressionNode(node: ts.Node): boolean {
1832 …return ts.isCallExpression(node) && node.expression && isPropertyAccessExpressionNode(node.express…
1835 function isGlobalBuilderCallExpressionNode(node: ts.Node): boolean {
1836 return ts.isCallExpression(node) && node.expression && ts.isIdentifier(node.expression) &&
1840 function isPropertyAccessExpressionNode(node: ts.Node): boolean {
1841 return ts.isPropertyAccessExpression(node) && node.expression &&
1842 node.expression.kind === ts.SyntaxKind.ThisKeyword && node.name && ts.isIdentifier(node.name) &&
1846 function processBindPopupBuilder(node: ts.CallExpression): ts.CallExpression {
1847 const newArguments: ts.Expression[] = [];
1848 node.arguments.forEach((argument: ts.ObjectLiteralExpression, index: number) => {
1856 node = ts.factory.updateCallExpression(node, node.expression, node.typeArguments, newArguments);
1860 function processDragStartBuilder(node: ts.CallExpression, propertyName: string): ts.CallExpression {
1861 const newStatements: ts.Statement[] = [];
1866 const statement: ts.Statement = node.arguments[0].body.statements[i];
1869 …node = ts.factory.updateCallExpression(node, node.expression, node.typeArguments, [ts.factory.upda…
1873 …node.arguments[0].equalsGreaterThanToken, ts.factory.updateBlock(node.arguments[0].body, newStatem…
1878 function isNodeFunction(node: ts.CallExpression): boolean {
1879 …return node.arguments && node.arguments.length && ts.isArrowFunction(node.arguments[0]) && node.ar…
1880 ts.isBlock(node.arguments[0].body);
1883 function checkStatement(statement: ts.Statement, propertyName: string): ts.Statement {
1884 if (ts.isReturnStatement(statement)) {
1885 if (ts.isObjectLiteralExpression(statement.expression)) {
1886 const newProperties: ts.ObjectLiteralElementLike[] = [];
1888 let property: ts.ObjectLiteralElementLike = statement.expression.properties[j];
1892 … return ts.factory.createReturnStatement(ts.factory.createObjectLiteralExpression(newProperties));
1894 let initializer: ts.Expression = statement.expression;
1896 return ts.factory.updateReturnStatement(statement, initializer);
1903 function checkProperty(property: ts.ObjectLiteralElementLike, propertyName: string): ts.ObjectLiter…
1905 let initializer: ts.Expression = property.initializer;
1907 property = ts.factory.createPropertyAssignment(property.name, initializer);
1912 function processInitializer(initializer: ts.Expression, propertyName: string): ts.Expression {
1913 if (initializer && ts.isConditionalExpression(initializer)) {
1914 …return processConditionalBuilder(initializer, ts.factory.createIdentifier(CUSTOM_COMPONENT_DEFAULT…
1916 } else if (isBuilderChangeNode(initializer, ts.factory.createIdentifier(CUSTOM_COMPONENT_DEFAULT),
1923 function isPropertyFunction(property: ts.ObjectLiteralElementLike): boolean {
1924 return ts.isPropertyAssignment(property) && property.name && ts.isIdentifier(property.name) &&
1928 function processBindPopupBuilderProperty(node: ts.ObjectLiteralExpression): ts.ObjectLiteralExpress…
1929 const newProperties: ts.PropertyAssignment[] = [];
1930 node.properties.forEach((property: ts.PropertyAssignment, index: number) => {
1931 if (property.name && ts.isIdentifier(property.name) && property.initializer &&
1933 let initializer: ts.Expression = property.initializer;
1935 newProperties.push(ts.factory.updatePropertyAssignment(property, property.name, initializer));
1940 return ts.factory.updateObjectLiteralExpression(node, newProperties);
1943 function processConditionalBuilder(initializer: ts.ConditionalExpression, identifierNode: ts.Identi…
1944 propertyName: string): ts.ConditionalExpression {
1945 let whenTrue: ts.Expression = initializer.whenTrue;
1946 let whenFalse: ts.Expression = initializer.whenFalse;
1953 return ts.factory.createConditionalExpression(
1962 function processPropertyBuilder(node: ts.PropertyAccessExpression): ts.ObjectLiteralExpression {
1963 return ts.factory.createObjectLiteralExpression([
1964 ts.factory.createPropertyAssignment(
1965 ts.factory.createIdentifier(BUILDER_ATTR_NAME),
1966 ts.factory.createCallExpression(
1967 ts.factory.createPropertyAccessExpression(
1969 ts.factory.createIdentifier(BUILDER_ATTR_BIND)
1972 [ts.factory.createThis()]
1978 function processPropertyBuilderWithoutKey(node: ts.PropertyAccessExpression): ts.CallExpression {
1979 return ts.factory.createCallExpression(
1980 ts.factory.createPropertyAccessExpression(
1982 ts.factory.createIdentifier(BUILDER_ATTR_BIND)
1985 [ts.factory.createThis()]
1989 function processIdentifierBuilder(node: ts.Identifier): ts.ObjectLiteralExpression {
1990 return ts.factory.createObjectLiteralExpression([
1991 ts.factory.createPropertyAssignment(
1992 ts.factory.createIdentifier(BUILDER_ATTR_NAME),
1993 ts.factory.createCallExpression(
1994ts.factory.createPropertyAccessExpression(node, ts.factory.createIdentifier(BUILDER_ATTR_BIND)),
1995 undefined, [ts.factory.createThis()]
2001 function processIdentifierBuilderWithoutKey(node: ts.Identifier): ts.CallExpression {
2002 return ts.factory.createCallExpression(
2003 ts.factory.createPropertyAccessExpression(node, ts.factory.createIdentifier(BUILDER_ATTR_BIND)),
2004 undefined, [ts.factory.createThis()]
2008 function getParsedBuilderAttrArgumentWithParams(node: ts.CallExpression):
2009 ts.ObjectLiteralExpression {
2010 return ts.factory.createObjectLiteralExpression([
2011 ts.factory.createPropertyAssignment(
2012 ts.factory.createIdentifier(BUILDER_ATTR_NAME),
2013 ts.factory.createArrowFunction(
2018 ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken),
2019 ts.factory.createBlock(
2020 [ts.factory.createExpressionStatement(ts.factory.createCallExpression(
2021ts.factory.createPropertyAccessExpression(node.expression, ts.factory.createIdentifier(CALL)
2022 ), undefined, [ts.factory.createThis(), ...node.arguments]))],
2030 function getParsedBuilderAttrArgumentWithParamsWithoutKey(node: ts.CallExpression):
2031 ts.ArrowFunction {
2032 return ts.factory.createArrowFunction(
2037 ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken),
2038 ts.factory.createBlock(
2039 [ts.factory.createExpressionStatement(ts.factory.createCallExpression(
2040 ts.factory.createPropertyAccessExpression(node.expression, ts.factory.createIdentifier(CALL)
2041 ), undefined, [ts.factory.createThis(), ...node.arguments]))],
2047 function validatePropertyAccessExpressionWithCustomBuilder(node: ts.Node): boolean {
2048 return ts.isPropertyAccessExpression(node) && node.name &&
2049 ts.isIdentifier(node.name) && CUSTOM_BUILDER_PROPERTIES.has(node.name.escapedText.toString());
2052 function validateIdentifierWithCustomBuilder(node: ts.Node): boolean {
2053 return ts.isIdentifier(node) && CUSTOM_BUILDER_PROPERTIES.has(node.escapedText.toString());
2056 function createArrowFunctionFor$$($$varExp: ts.Expression): ts.ArrowFunction {
2057 return ts.factory.createArrowFunction(
2059 [ts.factory.createParameterDeclaration(
2061 ts.factory.createIdentifier($$_NEW_VALUE),
2065 ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken),
2066 ts.factory.createBlock(
2067 [ts.factory.createExpressionStatement(ts.factory.createBinaryExpression(
2069 ts.factory.createToken(ts.SyntaxKind.EqualsToken),
2070 ts.factory.createIdentifier($$_NEW_VALUE)
2077 function updateArgumentFor$$(argument): ts.Expression {
2078 if (ts.isElementAccessExpression(argument)) {
2079 return ts.factory.updateElementAccessExpression(
2081 } else if (ts.isIdentifier(argument)) {
2084 return ts.factory.createThis();
2086 return ts.factory.createIdentifier(argument.getText().replace(/\$\$/, ''));
2088 } else if (ts.isPropertyAccessExpression(argument)) {
2089 return ts.factory.updatePropertyAccessExpression(
2095 function verifyComponentId(temp: any, node: ts.Identifier, propName: string,
2098 ts.isStringLiteral(temp.arguments[0])) {
2100 const posOfNode: ts.LineAndCharacter = transformLog.sourceFile
2127 function addComponentAttr(temp: any, node: ts.Identifier, lastStatement: any,
2128 statements: ts.Statement[], identifierNode: ts.Identifier, log: LogInfo[],
2129 isStylesAttr: boolean, immutableStatements: ts.Statement[], updateStatements: ts.Statement[],
2130 newImmutableStatements: ts.Statement[] = null, isRecycleComponent: boolean = false,
2136 const animationNullNode: ts.ExpressionStatement = ts.factory.createExpressionStatement(
2137 createFunction(ts.factory.createIdentifier(GLOBAL_CONTEXT), node,
2139 [ts.factory.createNull()]));
2142 temp.arguments[0].kind === ts.SyntaxKind.NullKeyword)) {
2148 lastStatement.statement = ts.factory.createExpressionStatement(createFunction(
2149 ts.factory.createIdentifier(GLOBAL_CONTEXT), node, temp.arguments));
2169 const extendNode: ts.Statement = ts.factory.createExpressionStatement(
2170 ts.factory.createCallExpression(ts.factory.createIdentifier(functionName), undefined,
2174 ...temp.arguments, ts.factory.createIdentifier(ELMTID),
2175 ts.factory.createIdentifier(ISINITIALRENDER),
2176 ts.factory.createThis()
2183 if (temp.arguments.length === 1 && ts.isObjectLiteralExpression(temp.arguments[0])) {
2195 const styleBlock: ts.Block =
2198 bindComponentAttr(styleBlock.statements[0] as ts.ExpressionStatement, identifierNode,
2201 bindComponentAttr(styleBlock.statements[0] as ts.ExpressionStatement, identifierNode,
2207 const argumentsArr: ts.Expression[] = [];
2209 const doubleDollarNode: ts.Statement = ts.factory.createExpressionStatement(
2222 const attrStatement: ts.Statement = ts.factory.createExpressionStatement(
2236 function isGestureType(node: ts.Identifier): boolean {
2240 function filterRegularAttrNode(argumentsNode: ts.NodeArray<ts.Expression>) {
2241 return argumentsNode.every((argument: ts.Expression) => {
2247 function isRegularAttrNode(node: ts.Expression): boolean {
2248 if (ts.isObjectLiteralExpression(node)) {
2249 return node.properties.every((propNode: ts.PropertyAssignment) => {
2256 if (ts.isArrayLiteralExpression(node)) {
2257 return node.elements.every((child: ts.Expression) => {
2266 if (ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.expression) &&
2267 ts.isIdentifier(node.name)) {
2272 const type: ts.Type = globalProgram.checker.getTypeAtLocation(node);
2282 if (ts.isPropertyAccessExpression(node)) {
2288 function isLiteralNode(node: ts.Expression): boolean {
2289 return ts.isStringLiteral(node) || ts.isNumericLiteral(node) || ts.isArrowFunction(node) ||
2290 [ts.SyntaxKind.TrueKeyword, ts.SyntaxKind.FalseKeyword].includes(node.kind);
2293 function traversePropNode(node: ts.PropertyAccessExpression, result: AttrResult): void {
2294 if (node.expression.kind === ts.SyntaxKind.ThisKeyword && ts.isIdentifier(node.name) &&
2299 if (ts.isPropertyAccessExpression(node.expression)) {
2304 function isDoubleDollarToChange(isStylesAttr: boolean, identifierNode: ts.Identifier,
2314 function isHaveDoubleDollar(param: ts.PropertyAssignment, name: string): boolean {
2315 return ts.isPropertyAssignment(param) && param.name && ts.isIdentifier(param.name) &&
2320 function loopEtscomponent(node: any, isStylesAttr: boolean): ts.Node {
2321 node.arguments.forEach((item: ts.Node, index: number) => {
2322 if (ts.isEtsComponentExpression(item)) {
2323 node.arguments[index] = ts.factory.createCallExpression(
2325 } else if ((ts.isCallExpression(item) || ts.isNewExpression(item)) &&
2327 node.arguments[index] = ts.visitEachChild(item,
2334 function changeEtsComponentKind(node: ts.Node): ts.Node {
2335 if (ts.isEtsComponentExpression(node)) {
2339 return ts.visitEachChild(node, changeEtsComponentKind, contextGlobal);
2342 function classifyArgumentsNum(args: any, argumentsArr: ts.Expression[], propName: string,
2343 identifierNode: ts.Identifier): void {
2345 const varExp: ts.Expression = updateArgumentFor$$(args[0]);
2350 const varExp: ts.Expression = updateArgumentFor$$(args[0]);
2355 function generateObjectFor$$(varExp: ts.Expression): ts.ObjectLiteralExpression {
2356 return ts.factory.createObjectLiteralExpression(
2358 ts.factory.createPropertyAssignment(
2359 ts.factory.createIdentifier($$_VALUE),
2362 ts.factory.createPropertyAssignment(
2363 ts.factory.createIdentifier($$_CHANGE_EVENT),
2371 function createViewStackProcessor(item: any, endViewStack: boolean): ts.ExpressionStatement {
2372 const argument: ts.StringLiteral[] = [];
2374 argument.push(ts.factory.createStringLiteral(item.name.getText()));
2376 return ts.factory.createExpressionStatement(ts.factory.createCallExpression(
2377 ts.factory.createPropertyAccessExpression(
2378 ts.factory.createIdentifier(VIEW_STACK_PROCESSOR),
2379 ts.factory.createIdentifier(VISUAL_STATE)
2386 function traverseStateStylesAttr(temp: any, statements: ts.Statement[],
2387 identifierNode: ts.Identifier, log: LogInfo[], updateStatements: ts.Statement[],
2388 newImmutableStatements: ts.Statement[] = null, isRecycleComponent: boolean = false): void {
2389 temp.arguments[0].properties.reverse().forEach((item: ts.PropertyAssignment) => {
2390 if (ts.isPropertyAccessExpression(item.initializer) &&
2394 bindComponentAttr(INNER_STYLE_FUNCTION.get(name).statements[0] as ts.ExpressionStatement,
2397 bindComponentAttr(INNER_STYLE_FUNCTION.get(name).statements[0] as ts.ExpressionStatement,
2400 } else if (ts.isIdentifier(item.initializer) &&
2403 bindComponentAttr(GLOBAL_STYLE_FUNCTION.get(name).statements[0] as ts.ExpressionStatement,
2406 bindComponentAttr(GLOBAL_STYLE_FUNCTION.get(name).statements[0] as ts.ExpressionStatement,
2409 } else if (ts.isObjectLiteralExpression(item.initializer) &&
2411 ts.isPropertyAssignment(item.initializer.properties[0])) {
2412 bindComponentAttr(ts.factory.createExpressionStatement(
2416 bindComponentAttr(ts.factory.createExpressionStatement(
2421 …if (!(ts.isObjectLiteralExpression(item.initializer) && item.initializer.properties.length === 0))…
2426 const viewNode: ts.Statement = createViewStackProcessor(item, false);
2439 function isExtendFunctionNode(identifierNode: ts.Identifier, propName: string,
2462 function parseGesture(node: ts.CallExpression, propName: string, statements: ts.Statement[],
2463 log: LogInfo[], updateStatements: ts.Statement[]): void {
2464 const popNode: ts.Statement = ts.factory.createExpressionStatement(
2465 createFunction(ts.factory.createIdentifier(COMPONENT_GESTURE),
2466 ts.factory.createIdentifier(COMPONENT_POP_FUNCTION), null));
2470 const argumentArr: ts.NodeArray<ts.PropertyAccessExpression> = ts.factory.createNodeArray(
2471 [ts.factory.createPropertyAccessExpression(
2472 ts.factory.createIdentifier(GESTURE_ENUM_KEY),
2473 ts.factory.createIdentifier(gestureMap.get(propName)))
2477 ts.isPropertyAccessExpression(node.arguments[1])) {
2481 const createNode: ts.Statement = ts.factory.createExpressionStatement(
2482 createFunction(ts.factory.createIdentifier(COMPONENT_GESTURE),
2483 ts.factory.createIdentifier(COMPONENT_CREATE_FUNCTION), argumentArr));
2488 function processGestureType(node: ts.CallExpression, statements: ts.Statement[], log: LogInfo[],
2489 updateStatements: ts.Statement[], reverse: boolean = false): void {
2490 const newStatements: ts.Statement[] = [];
2491 const newNode: ts.ExpressionStatement = ts.factory.createExpressionStatement(node);
2493 while (temp && !ts.isIdentifier(temp) && temp.expression) {
2496 if (temp && temp.parent && ts.isCallExpression(temp.parent) && ts.isIdentifier(temp) &&
2498 newStatements.push(ts.factory.createExpressionStatement(
2499 createFunction(temp, ts.factory.createIdentifier(COMPONENT_POP_FUNCTION), null)));
2501 const gestureStatements: ts.Statement[] = [];
2505 let argumentArr: ts.NodeArray<ts.Expression> = null;
2508 argumentArr = ts.factory.createNodeArray([temp.parent.arguments[0]]);
2510 newStatements.push(ts.factory.createExpressionStatement(
2511 createFunction(temp, ts.factory.createIdentifier(COMPONENT_CREATE_FUNCTION), argumentArr)));
2514 newStatements.push(ts.factory.createExpressionStatement(
2515 …createFunction(temp, ts.factory.createIdentifier(COMPONENT_CREATE_FUNCTION), temp.parent.arguments…
2524 function parseGestureInterface(node: ts.CallExpression, statements: ts.Statement[], log: LogInfo[],
2525 updateStatements: ts.Statement[], reverse: boolean = false): void {
2527 node.arguments.forEach((item: ts.Node) => {
2528 if (ts.isCallExpression(item)) {
2535 export function getName(node: ts.ExpressionStatement | ts.Expression): string {
2540 if (ts.isIdentifier(temp) && temp.parent && (ts.isCallExpression(temp.parent) ||
2541 ts.isEtsComponentExpression(temp.parent))) {
2544 } else if (ts.isPropertyAccessExpression(temp) && temp.name && ts.isIdentifier(temp.name) &&
2554 function isCustomAttributes(temp: ts.PropertyAccessExpression): boolean {
2557 …} else if (temp.expression && ts.isIdentifier(temp.expression) && temp.expression.getText() === $$…
2565 export function isAttributeNode(node: ts.ExpressionStatement): boolean {
2569 if (ts.isCallExpression(temp) && temp.expression && ts.isIdentifier(temp.expression)) {
2588 function isEtsComponent(node: ts.ExpressionStatement): boolean {
2592 if (ts.isEtsComponentExpression(temp)) {
2600 function isSomeName(forEachParameters: ts.NodeArray<ts.ParameterDeclaration>, name: string): boolea…
2603 return ts.isIdentifier(item.name) ? item.name.escapedText.toString() === name : false;
2607 function isParamFunction(node: ts.ExpressionStatement): boolean {
2608 return node.expression && ts.isCallExpression(node.expression) &&
2609 node.expression.expression && ts.isIdentifier(node.expression.expression);
2612 function getComponentType(node: ts.ExpressionStatement, log: LogInfo[], name: string,
2613 …parent: string, forEachParameters: ts.NodeArray<ts.ParameterDeclaration> = undefined): ComponentTy…
2637 ts.isCallExpression(node.expression) && ts.isIdentifier(node.expression.expression)) {
2649 function judgeBuilderType(node: ts.ExpressionStatement): boolean {
2650 let checker: ts.TypeChecker;
2657 const type: ts.Type = checker.getTypeAtLocation(node.expression.expression);
2673 function getEtsComponentExpression(node:ts.ExpressionStatement): ts.EtsComponentExpression {
2676 if (ts.isEtsComponentExpression(current)) {
2684 function checkEtsAndIdInIf(node:ts.ExpressionStatement, parent: string): [ts.EtsComponentExpression…
2686 let idName: ts.Expression;
2688 if (ts.isEtsComponentExpression(current)) {
2691 …if (!idName && parent === COMPONENT_IF && ts.isPropertyAccessExpression(current) && current.name &&
2692 ts.isIdentifier(current.name) && current.name.escapedText.toString() === ATTRIBUTE_ID &&
2701 function checkIdInIf(node:ts.ExpressionStatement, parent: string): ts.Expression {
2703 let idName: ts.Expression;
2705 if (parent === COMPONENT_IF && ts.isPropertyAccessExpression(current) && current.name &&
2706 ts.isIdentifier(current.name) && current.name.escapedText.toString() === ATTRIBUTE_ID &&
2716 function checkEtsComponent(node: ts.ExpressionStatement, log: LogInfo[]): void {
2717 const etsComponentExpression: ts.EtsComponentExpression = getEtsComponentExpression(node);
2728 function checkButtonParamHasLabel(node: ts.EtsComponentExpression, log: LogInfo[]): void {
2731 let argument: ts.Expression = node.arguments[i];
2732 …if (ts.isStringLiteral(argument) || (ts.isCallExpression(argument) && ts.isIdentifier(argument.exp…
2745 function isLazyForEachChild(node: ts.ExpressionStatement): boolean {
2747 while (temp && !ts.isEtsComponentExpression(temp) && !ts.isCallExpression(temp)) {
2750 …if (temp && temp.expression && (temp.expression as ts.Identifier).escapedText.toString() === COMPO…
2756 function processDollarEtsComponent(argumentsArr: ts.NodeArray<ts.Expression>, name: string): ts.Exp…
2757 const arr: ts.Expression[] = [];
2758 argumentsArr.forEach((item: ts.Expression, index: number) => {
2759 if (ts.isObjectLiteralExpression(item) && item.properties && item.properties.length) {
2760 const properties: ts.PropertyAssignment[] = [];
2761 item.properties.forEach((param: ts.PropertyAssignment, paramIndex: number) => {
2763 const varExp: ts.Expression = updateArgumentFor$$(param.initializer);
2764 …properties.push(ts.factory.updatePropertyAssignment(param, param.name, generateObjectFor$$(varExp)…
2769 arr.push(ts.factory.updateObjectLiteralExpression(item, properties));
2777 export function createFunction(node: ts.Identifier, attrNode: ts.Identifier,
2778 argumentsArr: ts.NodeArray<ts.Expression>): ts.CallExpression {
2793 return ts.factory.createCallExpression(
2794 ts.factory.createPropertyAccessExpression(
2803 function checkCreateArgumentBuilder(node: ts.Identifier, attrNode: ts.Identifier): boolean {
2811 function transformBuilder(argumentsArr: ts.NodeArray<ts.Expression>): ts.NodeArray<ts.Expression> {
2812 const newArguments: ts.Expression[] = [];
2813 argumentsArr.forEach((argument: ts.Expression) => {
2820 function parseCreateParameterBuilder(argument: ts.Expression):ts.Expression {
2821 if (ts.isObjectLiteralExpression(argument)) {