Lines Matching refs:ts
16 import ts from 'typescript';
150 export const simpleTypes: Set<ts.SyntaxKind> = new Set([ts.SyntaxKind.StringKeyword,
151 ts.SyntaxKind.NumberKeyword, ts.SyntaxKind.BooleanKeyword, ts.SyntaxKind.EnumDeclaration]);
160 private properity: ts.PropertyDeclaration;
161 private ctor: ts.ConstructorDeclaration;
162 private variableGet: ts.GetAccessorDeclaration;
163 private variableSet: ts.SetAccessorDeclaration;
164 private updateParams: ts.Statement;
166 private controllerSet: ts.MethodDeclaration;
167 private purgeVariableDepStatement: ts.Statement;
169 private stateVarsParams: ts.Statement;
171 public setProperity(updateItem: ts.PropertyDeclaration) {
176 public setCtor(updateCtor: ts.ConstructorDeclaration) {
181 public setControllerSet(updateControllerSet: ts.MethodDeclaration) {
185 public getControllerSet(): ts.MethodDeclaration {
189 public setVariableGet(updateVariableGet: ts.GetAccessorDeclaration) {
193 public setVariableSet(updateVariableSet: ts.SetAccessorDeclaration) {
197 public setUpdateParams(updateParams: ts.Statement) {
201 public setStateVarsParams(stateVarsParams: ts.Statement) {
209 public setPurgeVariableDepStatement(purgeVariableDepStatement: ts.Statement) {
225 public getProperity(): ts.PropertyDeclaration {
229 public getCtor(): ts.ConstructorDeclaration {
233 public getUpdateParams(): ts.Statement {
237 public getStateVarsParams(): ts.Statement {
241 public getPurgeVariableDepStatement(): ts.Statement {
245 public getVariableGet(): ts.GetAccessorDeclaration {
249 public getVariableSet(): ts.SetAccessorDeclaration {
264 export function processMemberVariableDecorators(parentName: ts.Identifier,
265 item: ts.PropertyDeclaration, ctorNode: ts.ConstructorDeclaration, watchMap: Map<string, ts.Node>,
266 …checkController: ControllerType, log: LogInfo[], program: ts.Program, context: ts.TransformationCo…
267 hasPreview: boolean, interfaceNode: ts.InterfaceDeclaration): UpdateResult {
269 const name: ts.Identifier = item.name as ts.Identifier;
270 const decorators: readonly ts.Decorator[] = ts.getAllDecorators(item); constant
300 function createStateVarsBody(name: ts.Identifier): ts.ExpressionStatement {
301 return ts.factory.createExpressionStatement(ts.factory.createCallExpression(
302 ts.factory.createPropertyAccessExpression(
303 ts.factory.createPropertyAccessExpression(
304 ts.factory.createThis(),
305 ts.factory.createIdentifier('__' + name.escapedText.toString())
307 ts.factory.createIdentifier(RESERT)
310 [ts.factory.createPropertyAccessExpression(
311 ts.factory.createIdentifier(COMPONENT_CONSTRUCTOR_PARAMS),
317 function createControllerSet(node: ts.PropertyDeclaration, componentName: ts.Identifier,
318 name: ts.Identifier, checkController: ControllerType): ts.MethodDeclaration {
322 return ts.factory.createMethodDeclaration(undefined, undefined,
323 ts.factory.createIdentifier(SET_CONTROLLER_METHOD), undefined, undefined,
324 [ts.factory.createParameterDeclaration(undefined, undefined,
325 ts.factory.createIdentifier(SET_CONTROLLER_CTR), undefined,
326 ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(SET_CONTROLLER_CTR_TYPE),
327 undefined), undefined)], undefined, ts.factory.createBlock(
328 [ts.factory.createExpressionStatement(ts.factory.createBinaryExpression(
329 ts.factory.createPropertyAccessExpression(ts.factory.createThis(), name),
330 ts.factory.createToken(ts.SyntaxKind.EqualsToken),
331 ts.factory.createIdentifier(SET_CONTROLLER_CTR)))], true));
335 function processPropertyNodeDecorator(parentName: ts.Identifier, node: ts.PropertyDeclaration,
336 updateResult: UpdateResult, ctorNode: ts.ConstructorDeclaration, name: ts.Identifier,
337 watchMap: Map<string, ts.Node>, log: LogInfo[], program: ts.Program,
338 context: ts.TransformationContext, hasPreview: boolean, interfaceNode: ts.InterfaceDeclaration):
340 const decorators: readonly ts.Decorator[] = ts.getAllDecorators(node); constant
387 function validateropertyDecorator(propertyDecorators: string[], name: ts.Identifier,
411 function processStateDecorators(node: ts.PropertyDeclaration, decorator: string,
412 updateResult: UpdateResult, ctorNode: ts.ConstructorDeclaration, log: LogInfo[],
413 program: ts.Program, context: ts.TransformationContext, hasPreview:boolean,
414 interfaceNode: ts.InterfaceDeclaration): void {
415 const name: ts.Identifier = node.name as ts.Identifier;
417 const updateState: ts.Statement[] = [];
418 const variableInitStatement: ts.Statement =
448 function createPurgeVariableDepStatement(variableWithUnderLink: string): ts.Statement {
449 return ts.factory.createExpressionStatement(
450 ts.factory.createCallExpression(
451 ts.factory.createPropertyAccessExpression(
452 ts.factory.createPropertyAccessExpression(
453 ts.factory.createThis(),
454 ts.factory.createIdentifier(variableWithUnderLink)
456 ts.factory.createIdentifier(PURGEDEPENDENCYONELMTID)
459 [ts.factory.createIdentifier(RMELMTID)]
464 function processWatch(node: ts.PropertyDeclaration, decorator: ts.Decorator,
465 watchMap: Map<string, ts.Node>, log: LogInfo[]): void {
468 if (decorator.expression && ts.isCallExpression(decorator.expression) &&
471 const argument: ts.Node = decorator.expression.arguments[0];
472 if (ts.isStringLiteral(argument)) {
482 } else if (ts.isIdentifier(decorator.expression.arguments[0])) {
484 … const propertyNode: ts.PropertyAccessExpression = createPropertyAccessExpressionWithThis(content);
488 } else if (ts.isPropertyAccessExpression(decorator.expression.arguments[0])) {
498 function createVariableInitStatement(node: ts.PropertyDeclaration, decorator: string,
499 log: LogInfo[], program: ts.Program, context: ts.TransformationContext, hasPreview: boolean,
500 interfaceNode: ts.InterfaceDeclaration): ts.Statement {
501 const name: ts.Identifier = node.name as ts.Identifier;
502 let type: ts.TypeNode;
503 let updateState: ts.ExpressionStatement;
544 members.push(ts.factory.createPropertySignature(undefined, name,
545 ts.factory.createToken(ts.SyntaxKind.QuestionToken), type));
546 interfaceNode = ts.factory.updateInterfaceDeclaration(interfaceNode,
547 ts.getModifiers(interfaceNode), interfaceNode.name, interfaceNode.typeParameters,
552 function wrongDecoratorInPreview(node: ts.PropertyDeclaration, decorator: string,
564 function createUpdateParams(name: ts.Identifier, decorator: string,
565 localInitializationNode: ts.PropertyDeclaration = undefined): ts.Statement {
566 let updateParamsNode: ts.Statement;
594 function createStateVarsParams(name: ts.Identifier, decorator: string): ts.Statement {
595 let updateParamsNode: ts.Statement;
607 function createUpdateParamsWithIf(name: ts.Identifier, isProp: boolean = false,
608 initializeNode: ts.Expression = undefined): ts.IfStatement {
609 return ts.factory.createIfStatement(ts.factory.createBinaryExpression(
610 ts.factory.createPropertyAccessExpression(
611 ts.factory.createIdentifier(CREATE_CONSTRUCTOR_PARAMS),
612 ts.factory.createIdentifier(name.escapedText.toString())),
613 isProp ? ts.factory.createToken(ts.SyntaxKind.EqualsEqualsEqualsToken) :
614 ts.factory.createToken(ts.SyntaxKind.ExclamationEqualsEqualsToken),
615 ts.factory.createIdentifier(COMPONENT_CONSTRUCTOR_UNDEFINED)),
616 isProp ? ts.factory.createBlock([createUpdateParamsWithSet(name, true, initializeNode)]) :
617 ts.factory.createBlock([
621 function createUpdateParamsForState(name: ts.Identifier): ts.IfStatement {
622 return ts.factory.createIfStatement(createPropertyAccessExpressionWithParams(name.getText()),
623 ts.factory.createBlock([createUpdateParamsWithSet(name)]));
626 function createUpdateParamsWithoutIf(name: ts.Identifier): ts.ExpressionStatement {
627 return ts.factory.createExpressionStatement(ts.factory.createBinaryExpression(
629 ts.factory.createToken(ts.SyntaxKind.EqualsToken),
633 function createUpdateParamsWithSet(name: ts.Identifier, hasElse: boolean = false,
634 initializeNode: ts.Expression = undefined): ts.ExpressionStatement {
635 return ts.factory.createExpressionStatement(ts.factory.createCallExpression(
636 …ts.factory.createPropertyAccessExpression(createPropertyAccessExpressionWithThis(`__${name.getText…
637 ts.factory.createIdentifier(CREATE_SET_METHOD)), undefined,
641 function updateNormalProperty(node: ts.PropertyDeclaration, name: ts.Identifier,
642 log: LogInfo[], context: ts.TransformationContext): ts.ExpressionStatement {
643 const init: ts.Expression =
644 ts.visitNode(node.initializer, visitDialogController);
645 function visitDialogController(node: ts.Node): ts.Node {
647 node = createReference(node as ts.PropertyAssignment, log);
649 return ts.visitEachChild(node, visitDialogController, context);
651 return ts.factory.createExpressionStatement(ts.factory.createBinaryExpression(
653 ts.factory.createToken(ts.SyntaxKind.EqualsToken), init ||
654 ts.factory.createIdentifier(COMPONENT_CONSTRUCTOR_UNDEFINED)));
657 function updateObservedProperty(item: ts.PropertyDeclaration, name: ts.Identifier,
658 type: ts.TypeNode, program: ts.Program): ts.ExpressionStatement {
659 return ts.factory.createExpressionStatement(ts.factory.createBinaryExpression(
661 ts.factory.createToken(ts.SyntaxKind.EqualsToken), ts.factory.createNewExpression(
662 ts.factory.createIdentifier(isSimpleType(type, program) ? OBSERVED_PROPERTY_SIMPLE :
663 OBSERVED_PROPERTY_OBJECT), undefined, [item.initializer, ts.factory.createThis(),
664 ts.factory.createStringLiteral(name.escapedText.toString())])));
667 function updateSynchedPropertyTwoWay(nameIdentifier: ts.Identifier, type: ts.TypeNode,
668 program: ts.Program): ts.ExpressionStatement {
676 function updateSynchedPropertyOneWay(nameIdentifier: ts.Identifier, type: ts.TypeNode,
677 decoractor: string, log: LogInfo[], program: ts.Program): ts.ExpressionStatement {
687 export function findDecoratorIndex(decorators: readonly ts.Decorator[], nameList: string[]): number…
688 return decorators.findIndex((item: ts.Decorator) => {
693 function updateStoragePropAndLinkProperty(node: ts.PropertyDeclaration, name: ts.Identifier,
694 decorator: string): ts.ExpressionStatement {
695 const decorators: readonly ts.Decorator[] = ts.getAllDecorators(node); constant
700 const storageValue: ts.Expression[] = [
703 ts.factory.createThis(), constant
704 ts.factory.createStringLiteral(name.getText())
716 return ts.factory.createExpressionStatement(ts.factory.createBinaryExpression(
718 ts.factory.createToken(ts.SyntaxKind.EqualsToken), ts.factory.createCallExpression(
719 ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier(storageFuncName),
720 ts.factory.createIdentifier(setFuncName)), undefined, storageValue)));
724 function getDecoratorKey(node: ts.PropertyDeclaration, isProvided: boolean = false): [string, boole…
728 const decorators: readonly ts.Decorator[] = ts.getAllDecorators(node); constant
731 let keyNameNode: ts.Node = decorators[index].expression.arguments[0];
732 if (ts.isIdentifier(keyNameNode)) {
735 } else if (ts.isStringLiteral(keyNameNode)) {
738 …} else if (isProvided && ts.isObjectLiteralExpression(keyNameNode) && keyNameNode.properties.lengt…
739 ts.isPropertyAssignment(keyNameNode.properties[0]) && keyNameNode.properties[0].initializer) {
749 function updateSynchedPropertyNesedObject(nameIdentifier: ts.Identifier,
750 type: ts.TypeNode, decoractor: string, log: LogInfo[]): ts.ExpressionStatement {
759 function updateConsumeProperty(node: ts.PropertyDeclaration,
760 nameIdentifier: ts.Identifier): ts.ExpressionStatement {
763 const propertyAndStringKey: [string?, boolean?, ts.Node?, boolean?] = []; constant
770 return ts.factory.createExpressionStatement(ts.factory.createBinaryExpression(
772 ts.factory.createToken(ts.SyntaxKind.EqualsToken), ts.factory.createCallExpression(
774 propertyAndStringKey.length === 0 ? ts.factory.createStringLiteral(propertyOrAliasName) :
775 …propertyAndStringKey.length === 4 && propertyAndStringKey[2] as ts.Expression, ts.factory.createSt…
778 function updateBuilderParamProperty(node: ts.PropertyDeclaration,
779 nameIdentifier: ts.Identifier, log: LogInfo[]): ts.ExpressionStatement {
788 return ts.factory.createExpressionStatement(ts.factory.createBinaryExpression(
789 createPropertyAccessExpressionWithThis(name), ts.factory.createToken(ts.SyntaxKind.EqualsToken),
790 node.initializer || ts.factory.createIdentifier(COMPONENT_CONSTRUCTOR_UNDEFINED)
794 function judgeBuilderParamAssignedByBuilder(node: ts.PropertyDeclaration): boolean {
795 return node.initializer && !(node.initializer && (ts.isIdentifier(node.initializer) &&
797 ts.isPropertyAccessExpression(node.initializer) && node.initializer.name &&
798 ts.isIdentifier(node.initializer.name) &&
800 isWrappedBuilder(node.initializer as ts.PropertyAccessExpression)));
803 export function createViewCreate(node: ts.NewExpression | ts.Identifier): ts.CallExpression {
805 return createFunction(ts.factory.createIdentifier(BASE_COMPONENT_NAME_PU),
806 ts.factory.createIdentifier(COMPONENT_CREATE_FUNCTION), ts.factory.createNodeArray([node]));
808 return createFunction(ts.factory.createIdentifier(BASE_COMPONENT_NAME),
809 ts.factory.createIdentifier(COMPONENT_CREATE_FUNCTION), ts.factory.createNodeArray([node]));
812 export function createCustomComponentNewExpression(node: ts.CallExpression, name: string,
814 isCutomDialog: boolean = false): ts.NewExpression {
815 const newNode: ts.NewExpression = ts.factory.createNewExpression(node.expression,
820 function addCustomComponentId(node: ts.NewExpression, componentName: string,
822 isCutomDialog: boolean = false): ts.NewExpression {
829 let argumentsArray: ts.Expression[];
835 argumentsArray = [ts.factory.createObjectLiteralExpression([], true)];
839 argumentsArray.unshift(isBuilder ? ts.factory.createBinaryExpression(
840 …ts.factory.createStringLiteral(path.basename(transformLog.sourceFile.fileName, EXTNAME_ETS) + '_'),
841 … ts.factory.createToken(ts.SyntaxKind.PlusToken), ts.factory.createIdentifier(_GENERATE_ID)) :
842 ts.factory.createStringLiteral(componentInfo.id.toString()),
843 isBuilder ? parentConditionalExpression() : ts.factory.createThis());
845 … argumentsArray.unshift(isGlobalBuilder ? parentConditionalExpression() : ts.factory.createThis());
846 argumentsArray.push(ts.factory.createIdentifier(COMPONENT_IF_UNDEFINED),
847 isCutomDialog ? ts.factory.createPrefixUnaryExpression(
848 ts.SyntaxKind.MinusToken,
849 ts.factory.createNumericLiteral('1')) : ts.factory.createIdentifier(ELMTID),
850 createArrowFunctionNode(), ts.factory.createObjectLiteralExpression(
852 ts.factory.createPropertyAssignment(
853 ts.factory.createIdentifier('page'),
854 … ts.factory.createStringLiteral(path.relative(process.cwd(), resourceFileName).replace(/\\/g, '/'))