Lines Matching refs:ts
16 import ts from 'typescript';
115 export function processCustomComponent(node: ts.ExpressionStatement, newStatements: ts.Statement[],
117 idName: ts.Expression = undefined): void {
125 const componentNode: ts.CallExpression = getCustomComponentNode(node);
129 ts.isPropertyAccessExpression(componentNode.parent);
131 let customComponentNewExpression: ts.NewExpression = createCustomComponentNewExpression(
133 let argumentsArray: ts.PropertyAssignment[];
138 argumentsArray.forEach((item: ts.PropertyAssignment, index: number) => {
141 const propertyAssignmentNode: ts.PropertyAssignment = ts.factory.updatePropertyAssignment(
142 item, item.name, changeNodeFromCallToArrow(item.initializer as ts.CallExpression));
147 const newNode: ts.ExpressionStatement = ts.factory.updateExpressionStatement(node,
148 ts.factory.createNewExpression(componentNode.expression, componentNode.typeArguments,
149 [ts.factory.createObjectLiteralExpression(argumentsArray, true)]));
151 newNode.expression as ts.CallExpression, name, isBuilder);
160 const commomComponentNode: ts.Statement[] = [ts.factory.createExpressionStatement(
161 createFunction(ts.factory.createIdentifier(COMPONENT_COMMON),
162 ts.factory.createIdentifier(COMPONENT_CREATE_FUNCTION), null))];
163 const immutableStatements: ts.Statement[] = [];
164 bindComponentAttr(node, ts.factory.createIdentifier(COMPONENT_COMMON), commomComponentNode,
169 newStatements.push(ts.factory.createExpressionStatement(
170 createFunction(ts.factory.createIdentifier(COMPONENT_COMMON),
171 ts.factory.createIdentifier(COMPONENT_CREATE_FUNCTION), null)));
172 bindComponentAttr(node, ts.factory.createIdentifier(COMPONENT_COMMON), newStatements, log);
181 newStatements.push(ts.factory.createExpressionStatement(
182 createFunction(ts.factory.createIdentifier(COMPONENT_COMMON),
183 ts.factory.createIdentifier(COMPONENT_POP_FUNCTION), null)));
199 function createRecycleComponent(isGlobalBuilder: boolean): ts.Statement {
201 [ts.factory.createExpressionStatement(
202 createFunction(ts.factory.createIdentifier(COMPONENT_RECYCLE),
203 ts.factory.createIdentifier(COMPONENT_CREATE_FUNCTION), null))
207 function componentAttributes(componentName: string): ts.Statement {
208 return ts.factory.createExpressionStatement(
209 ts.factory.createCallExpression(
210 ts.factory.createPropertyAccessExpression(
211 ts.factory.createIdentifier(componentName),
212 ts.factory.createIdentifier(COMPONENT_POP_FUNCTION)
217 function isHasChild(node: ts.CallExpression): boolean {
218 return node.arguments && node.arguments[0] && ts.isObjectLiteralExpression(node.arguments[0]) &&
222 function isToChange(item: ts.PropertyAssignment, name: string): boolean {
224 if (item.initializer && ts.isCallExpression(item.initializer) && builderParamName &&
232 function changeNodeFromCallToArrow(node: ts.CallExpression): ts.ArrowFunction {
233 let builderBindThis: ts.ExpressionStatement = ts.factory.createExpressionStatement(node);
234 if (ts.isCallExpression(node) && node.expression && ts.isIdentifier(node.expression) &&
236 …builderBindThis = transferBuilderCall(ts.factory.createExpressionStatement(node), node.expression.…
238 return ts.factory.createArrowFunction(undefined, undefined, [], undefined,
239 ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken),
240 ts.factory.createBlock([builderBindThis], true));
243 function addCustomComponent(node: ts.ExpressionStatement, newStatements: ts.Statement[],
244 newNode: ts.NewExpression, log: LogInfo[], name: string, componentNode: ts.CallExpression,
247 if (ts.isNewExpression(newNode)) {
248 const propertyArray: ts.ObjectLiteralElementLike[] = [];
255 function addCustomComponentStatements(node: ts.ExpressionStatement, newStatements: ts.Statement[],
256 newNode: ts.NewExpression, name: string, props: ts.ObjectLiteralElementLike[],
257 componentNode: ts.CallExpression, isBuilder: boolean, isGlobalBuilder: boolean,
262 ts.factory.updateExpressionStatement(node, createViewCreate(newNode)),
263 ts.factory.createObjectLiteralExpression(props, true), name));
270 function createChildElmtId(node: ts.CallExpression, name: string): ts.PropertyAssignment[] {
272 const childParam: ts.PropertyAssignment[] = [];
281 …if (ts.isIdentifier(item.name) && propsAndObjectLinks.includes(item.name.escapedText.toString())) {
289 function createCustomComponent(newNode: ts.NewExpression, name: string, componentNode: ts.CallExpre…
291 componentAttrInfo: ComponentAttrInfo): ts.Block {
292 let componentParameter: ts.ObjectLiteralExpression;
294 …componentParameter = ts.factory.createObjectLiteralExpression(createChildElmtId(componentNode, nam…
296 componentParameter = ts.factory.createObjectLiteralExpression([], false);
298 const arrowArgArr: ts.ParameterDeclaration[] = [
299 ts.factory.createParameterDeclaration(undefined, undefined, undefined,
300 ts.factory.createIdentifier(ELMTID)
302 ts.factory.createParameterDeclaration(undefined, undefined, undefined,
303 ts.factory.createIdentifier(ISINITIALRENDER)
306 const arrowBolck: ts.Statement[] = [
311 arrowArgArr.push(ts.factory.createParameterDeclaration(
312 undefined, undefined, undefined, ts.factory.createIdentifier(RECYCLE_NODE),
313 undefined, undefined, ts.factory.createNull()
320 const observeArgArr: ts.Node[] = [
321 ts.factory.createArrowFunction(undefined, undefined, arrowArgArr, undefined,
322 ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken),
323 ts.factory.createBlock(arrowBolck, true))
327 observeArgArr.unshift(ts.factory.createStringLiteral(name));
329 observeArgArr.push(ts.factory.createNull());
331 return ts.factory.createBlock(
333 ts.factory.createExpressionStatement(ts.factory.createCallExpression(
334 ts.factory.createPropertyAccessExpression(isGlobalBuilder ?
335 … ts.factory.createParenthesizedExpression(parentConditionalExpression()) : ts.factory.createThis(),
337 ts.factory.createIdentifier(OBSERVE_RECYCLE_COMPONENT_CREATION) :
338 ts.factory.createIdentifier(partialUpdateConfig.optimizeComponent ?
341 undefined, observeArgArr as ts.Expression[]))
345 function assignRecycleParams(): ts.IfStatement {
346 return ts.factory.createIfStatement(
347 ts.factory.createIdentifier(RECYCLE_NODE),
348 ts.factory.createBlock(
349 [ts.factory.createExpressionStatement(ts.factory.createBinaryExpression(
350 ts.factory.createPropertyAccessExpression(
351 ts.factory.createIdentifier(RECYCLE_NODE),
352 ts.factory.createIdentifier(COMPONENT_PARAMS_FUNCTION)
354 ts.factory.createToken(ts.SyntaxKind.EqualsToken),
355 ts.factory.createIdentifier(COMPONENT_PARAMS_LAMBDA_FUNCTION)
363 export function assignComponentParams(componentNode: ts.CallExpression,
364 isBuilder: boolean = false): ts.VariableStatement {
366 …const [keyArray, valueArray]: [ts.Node[], ts.Node[]] = splitComponentParams(componentNode, isBuild… constant
371 return ts.factory.createVariableStatement(
373 ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(
374 ts.factory.createIdentifier(COMPONENT_PARAMS_LAMBDA_FUNCTION),
377 ts.factory.createArrowFunction(
382 ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken),
383 ts.factory.createBlock(
384 [ts.factory.createReturnStatement(
385 integrateParams ? componentNode.arguments[0] : ts.factory.createObjectLiteralExpression(
394 ts.NodeFlags.Let
398 function reWriteComponentParams(keyArray: ts.Node[], valueArray: ts.Node[]): (ts.PropertyAssignment…
399 ts.ShorthandPropertyAssignment)[] {
400 const returnProperties: (ts.PropertyAssignment | ts.ShorthandPropertyAssignment)[] = [];
401 keyArray.forEach((item: ts.Identifier, index: number) => {
403 returnProperties.push(ts.factory.createShorthandPropertyAssignment(
408 returnProperties.push(ts.factory.createPropertyAssignment(
410 valueArray[index] as ts.Identifier
417 … splitComponentParams(componentNode: ts.CallExpression, isBuilder: boolean, isParamsLambda: boolea…
418 const keyArray: ts.Node[] = [];
419 const valueArray: ts.Node[] = [];
421 …ts.isObjectLiteralExpression(componentNode.arguments[0]) && componentNode.arguments[0].properties)…
422 componentNode.arguments[0].properties.forEach((propertyItem: ts.PropertyAssignment) => {
423 const newPropertyItem: ts.PropertyAssignment =
432 function createIfCustomComponent(newNode: ts.NewExpression, componentNode: ts.CallExpression,
433 …componentParameter: ts.ObjectLiteralExpression, name: string, isGlobalBuilder: boolean, isBuilder:…
434 isRecycleComponent: boolean, componentAttrInfo: ComponentAttrInfo): ts.IfStatement {
435 return ts.factory.createIfStatement(
436 ts.factory.createIdentifier(ISINITIALRENDER),
437 ts.factory.createBlock(
444 ts.factory.createBlock(
445 [ts.factory.createExpressionStatement(ts.factory.createCallExpression(
446 ts.factory.createPropertyAccessExpression(isGlobalBuilder ?
447 … ts.factory.createParenthesizedExpression(parentConditionalExpression()) : ts.factory.createThis(),
448 ts.factory.createIdentifier(UPDATE_STATE_VARS_OF_CHIND_BY_ELMTID)
450 [ts.factory.createIdentifier(ELMTID), componentParameter]))], true)
454 function createNewComponent(newNode: ts.NewExpression): ts.Statement {
455 return ts.factory.createExpressionStatement(
456 ts.factory.createCallExpression(
457 ts.factory.createPropertyAccessExpression(
458 ts.factory.createIdentifier(BASE_COMPONENT_NAME_PU),
459 ts.factory.createIdentifier(COMPONENT_CREATE_FUNCTION)
463 function createNewRecycleComponent(newNode: ts.NewExpression, componentNode: ts.CallExpression,
464 name: string, componentAttrInfo: ComponentAttrInfo): ts.Statement {
465 let argNode: ts.Expression[] = [];
466 const componentParam: ts.PropertyAssignment[] = [];
468 …ts.isObjectLiteralExpression(componentNode.arguments[0]) && componentNode.arguments[0].properties)…
469 componentNode.arguments[0].properties.forEach((propertyItem: ts.PropertyAssignment) => {
470 …const newPropertyItem: ts.PropertyAssignment = createReference(propertyItem, [], false, false, tru…
473 argNode = [ts.factory.createObjectLiteralExpression(componentParam, false)];
475 argNode = [ts.factory.createObjectLiteralExpression([], false)];
477 const recycleNode: ts.CallExpression = ts.factory.createCallExpression(
479 return ts.factory.createExpressionStatement(
480 ts.factory.createCallExpression(
481 ts.factory.createPropertyAccessExpression(
482 ts.factory.createIdentifier(BASE_COMPONENT_NAME_PU),
483 ts.factory.createIdentifier(COMPONENT_CREATE_RECYCLE)
486 ts.factory.createConditionalExpression(
487 ts.factory.createIdentifier(RECYCLE_NODE),
488 ts.factory.createToken(ts.SyntaxKind.QuestionToken),
489 ts.factory.createIdentifier(RECYCLE_NODE),
490 ts.factory.createToken(ts.SyntaxKind.ColonToken),
493 ts.factory.createBinaryExpression(
494 ts.factory.createIdentifier(RECYCLE_NODE),
495 ts.factory.createToken(ts.SyntaxKind.ExclamationEqualsEqualsToken),
496 ts.factory.createNull()
498 componentAttrInfo.reuseId ? componentAttrInfo.reuseId as ts.Expression :
499 ts.factory.createStringLiteral(name),
500 ts.factory.createArrowFunction(undefined, undefined, [], undefined,
501 ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken),
502 ts.factory.createBlock([
503 ts.factory.createIfStatement(
504 ts.factory.createBinaryExpression(
505 ts.factory.createIdentifier(RECYCLE_NODE),
506 ts.factory.createToken(ts.SyntaxKind.AmpersandAmpersandToken),
507 ts.factory.createBinaryExpression(
508 ts.factory.createTypeOfExpression(
510 ts.factory.createToken(ts.SyntaxKind.EqualsEqualsEqualsToken),
511 ts.factory.createStringLiteral(FUNCTION)
513 ts.factory.createBlock([
514 ts.factory.createExpressionStatement(ts.factory.createCallExpression(
520 ts.factory.createBlock(
522 ts.factory.createIfStatement(ts.factory.createBinaryExpression(
523 …createRecyclePropertyNode(ABOUT_TO_REUSE), ts.factory.createToken(ts.SyntaxKind.AmpersandAmpersand…
524 ts.factory.createBinaryExpression(
525 ts.factory.createTypeOfExpression(createRecyclePropertyNode(ABOUT_TO_REUSE)),
526 ts.factory.createToken(ts.SyntaxKind.EqualsEqualsEqualsToken),
527 ts.factory.createStringLiteral(FUNCTION)
529 … ts.factory.createBlock([ts.factory.createExpressionStatement(recycleNode)], true)),
530 ts.factory.createExpressionStatement(ts.factory.createCallExpression(
540 function createRecyclePropertyNode(recycleFunctionName: string): ts.PropertyAccessExpression {
541 return ts.factory.createPropertyAccessExpression(
542 ts.factory.createIdentifier(RECYCLE_NODE), ts.factory.createIdentifier(recycleFunctionName));
545 function validateCustomComponentPrams(node: ts.CallExpression, name: string,
546 props: ts.ObjectLiteralElementLike[], log: LogInfo[], isBuilder: boolean): void {
548 const nodeArguments: ts.NodeArray<ts.Expression> = node.arguments;
552 ts.isObjectLiteralExpression(nodeArguments[0])) {
553 const nodeArgument: ts.ObjectLiteralExpression = nodeArguments[0] as ts.ObjectLiteralExpression;
555 if (item.name && ts.isIdentifier(item.name)) {
560 if (isToChange(item as ts.PropertyAssignment, name)) {
561 item = ts.factory.updatePropertyAssignment(item as ts.PropertyAssignment,
574 function getCustomComponentNode(node: ts.ExpressionStatement): ts.CallExpression {
579 if (ts.isIdentifier(temp)) {
588 if (ts.isExpressionStatement(parent)) {
591 if (ts.isCallExpression(parent) || ts.isEtsComponentExpression(parent)) {
608 function isThisProperty(node: ts.ObjectLiteralElementLike, propertySet: Set<string>): boolean {
609 if (ts.isPropertyAssignment(node) && ts.isIdentifier(node.name) &&
616 function isNonThisProperty(node: ts.ObjectLiteralElementLike, propertySet: Set<string>): boolean {
617 if (ts.isPropertyAssignment(node) && ts.isIdentifier(node.name) &&
619 ts.isPropertyAccessExpression(node.initializer) && node.initializer.expression &&
620 node.initializer.expression.kind === ts.SyntaxKind.ThisKeyword &&
621 …ts.isIdentifier(node.initializer.name) && node.initializer.name.escapedText.toString().includes('$…
624 if (ts.isPropertyAssignment(node) && ts.isIdentifier(node.name) &&
631 function validateStateManagement(node: ts.ObjectLiteralElementLike, customComponentName: string,
637 function checkFromParentToChild(node: ts.ObjectLiteralElementLike, customComponentName: string,
640 if (ts.isIdentifier(node.name)) {
648 getParentPropertyName(node as ts.PropertyAssignment, curPropertyKind, log);
657 } else if (isInitFromLocal(node) && ts.isPropertyAssignment(node) &&
664 (ts.isPropertyAccessExpression(node.initializer) ||
665 ts.isElementAccessExpression(node.initializer) || ts.isIdentifier(node.initializer))) {
669 getParentPropertyName(node as ts.PropertyAssignment, curPropertyKind, log) || propertyName;
689 function judgeStructAssigned$$(node: ts.ObjectLiteralElementLike): boolean {
691 ts.isPropertyAccessExpression(node.initializer) &&
692 node.initializer.expression && ts.isIdentifier(node.initializer.expression) &&
696 function isInitFromParent(node: ts.ObjectLiteralElementLike): boolean {
697 if (ts.isPropertyAssignment(node) && node.initializer) {
698 if (ts.isPropertyAccessExpression(node.initializer) && node.initializer.expression &&
699 node.initializer.expression.kind === ts.SyntaxKind.ThisKeyword &&
700 ts.isIdentifier(node.initializer.name)) {
702 } else if (ts.isIdentifier(node.initializer) &&
709 function isInitFromLocal(node: ts.ObjectLiteralElementLike): boolean {
710 if (ts.isPropertyAssignment(node) && ts.isIdentifier(node.initializer) &&
716 function getParentPropertyName(node: ts.PropertyAssignment, curPropertyKind: string,
718 const initExpression: ts.Expression = node.initializer;
725 const initName: ts.Identifier = initExpression.name || initExpression;
772 function createFindChildById(id: string, name: string, isBuilder: boolean = false): ts.VariableStat…
773 return ts.factory.createVariableStatement(undefined, ts.factory.createVariableDeclarationList(
774 [ts.factory.createVariableDeclaration(ts.factory.createIdentifier(
775 … `${CUSTOM_COMPONENT_EARLIER_CREATE_CHILD}${id}`), undefined, ts.factory.createTypeReferenceNode(
776 ts.factory.createIdentifier(name)),
777 ts.factory.createConditionalExpression(
778 ts.factory.createParenthesizedExpression(
779 ts.factory.createBinaryExpression(
781 ts.factory.createToken(ts.SyntaxKind.AmpersandAmpersandToken),
782 ts.factory.createPropertyAccessExpression(
784 ts.factory.createIdentifier(CUSTOM_COMPONENT_FUNCTION_FIND_CHILD_BY_ID)
785 ))), ts.factory.createToken(ts.SyntaxKind.QuestionToken),
786 ts.factory.createAsExpression(ts.factory.createCallExpression(
787 ts.factory.createPropertyAccessExpression(createConditionParent(isBuilder),
788 ts.factory.createIdentifier(`${CUSTOM_COMPONENT_FUNCTION_FIND_CHILD_BY_ID}`)), undefined,
789 [isBuilder ? ts.factory.createCallExpression(ts.factory.createIdentifier(GENERATE_ID),
790 undefined, []) : ts.factory.createStringLiteral(id)]),
791 ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(name))),
792 ts.factory.createToken(ts.SyntaxKind.ColonToken),
793 ts.factory.createIdentifier(COMPONENT_IF_UNDEFINED)))], ts.NodeFlags.Let));
796 export function createConditionParent(isBuilder: boolean): ts.ParenthesizedExpression | ts.ThisExpr…
797 …return isBuilder ? ts.factory.createParenthesizedExpression(parentConditionalExpression()) : ts.fa…
800 function createCustomComponentIfStatement(id: string, node: ts.ExpressionStatement,
801 newObjectLiteralExpression: ts.ObjectLiteralExpression, parentName: string): ts.IfStatement {
803 return ts.factory.createIfStatement(ts.factory.createBinaryExpression(
804 ts.factory.createIdentifier(viewName),
805 ts.factory.createToken(ts.SyntaxKind.EqualsEqualsToken),
806 ts.factory.createIdentifier(`${COMPONENT_CONSTRUCTOR_UNDEFINED}`)),
807 ts.factory.createBlock([node], true),
808 ts.factory.createBlock([ts.factory.createExpressionStatement(ts.factory.createCallExpression(
809 ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier(
810 viewName), ts.factory.createIdentifier(
813 ts.factory.createExpressionStatement(ts.factory.createCallExpression(
814 ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier(`${BASE_COMPONENT_NAME}`),
815 ts.factory.createIdentifier(`${COMPONENT_CREATE_FUNCTION}`)), undefined,
816 [ts.factory.createIdentifier(viewName)]))], true));
819 function createStaticIf(name: string): ts.IfStatement {
820 return ts.factory.createIfStatement(ts.factory.createPrefixUnaryExpression(
821 ts.SyntaxKind.ExclamationToken, ts.factory.createCallExpression(
822 ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier(name),
823 ts.factory.createIdentifier(CUSTOM_COMPONENT_NEEDS_UPDATE_FUNCTION)), undefined, [])),
824 ts.factory.createBlock([ts.factory.createExpressionStatement(ts.factory.createCallExpression(
825 ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier(name),
826 ts.factory.createIdentifier(CUSTOM_COMPONENT_MARK_STATIC_FUNCTION)),
830 function hasDollar(initExpression: ts.Expression): boolean {
831 if (ts.isPropertyAccessExpression(initExpression) &&
834 } else if (ts.isIdentifier(initExpression) && matchStartWithDollar(initExpression.getText())) {
845 function validateForbiddenToInitViaParam(node: ts.ObjectLiteralElementLike,
864 function validateNonExistentProperty(node: ts.ObjectLiteralElementLike,
873 function validateMandatoryToAssignmentViaParam(node: ts.CallExpression, customComponentName: string,
889 function validateMandatoryToInitViaParam(node: ts.CallExpression, customComponentName: string,
906 function validateInitDecorator(node: ts.CallExpression, customComponentName: string,
926 function validateIllegalInitFromParent(node: ts.ObjectLiteralElementLike, propertyName: string,
945 function validateLinkWithoutDollar(node: ts.PropertyAssignment, log: LogInfo[]): void {
954 function validateNonLinkWithDollar(node: ts.PropertyAssignment, log: LogInfo[]): void {