• Home
  • Raw
  • Download

Lines Matching refs:ts

16 import ts from 'typescript';
146 export const simpleTypes: Set<ts.SyntaxKind> = new Set([ts.SyntaxKind.StringKeyword,
147 ts.SyntaxKind.NumberKeyword, ts.SyntaxKind.BooleanKeyword, ts.SyntaxKind.EnumDeclaration]);
156 private properity: ts.PropertyDeclaration;
157 private ctor: ts.ConstructorDeclaration;
158 private variableGet: ts.GetAccessorDeclaration;
159 private variableSet: ts.SetAccessorDeclaration;
160 private updateParams: ts.Statement;
162 private controllerSet: ts.MethodDeclaration;
163 private purgeVariableDepStatement: ts.Statement;
165 private stateVarsParams: ts.Statement;
167 public setProperity(updateItem: ts.PropertyDeclaration) {
172 public setCtor(updateCtor: ts.ConstructorDeclaration) {
177 public setControllerSet(updateControllerSet: ts.MethodDeclaration) {
181 public getControllerSet(): ts.MethodDeclaration {
185 public setVariableGet(updateVariableGet: ts.GetAccessorDeclaration) {
189 public setVariableSet(updateVariableSet: ts.SetAccessorDeclaration) {
193 public setUpdateParams(updateParams: ts.Statement) {
197 public setStateVarsParams(stateVarsParams: ts.Statement) {
205 public setPurgeVariableDepStatement(purgeVariableDepStatement: ts.Statement) {
221 public getProperity(): ts.PropertyDeclaration {
225 public getCtor(): ts.ConstructorDeclaration {
229 public getUpdateParams(): ts.Statement {
233 public getStateVarsParams(): ts.Statement {
237 public getPurgeVariableDepStatement(): ts.Statement {
241 public getVariableGet(): ts.GetAccessorDeclaration {
245 public getVariableSet(): ts.SetAccessorDeclaration {
260 export function processMemberVariableDecorators(parentName: ts.Identifier,
261 item: ts.PropertyDeclaration, ctorNode: ts.ConstructorDeclaration, watchMap: Map<string, ts.Node>,
262 …checkController: ControllerType, log: LogInfo[], program: ts.Program, context: ts.TransformationCo…
263 hasPreview: boolean, interfaceNode: ts.InterfaceDeclaration): UpdateResult {
265 const name: ts.Identifier = item.name as ts.Identifier;
292 function createStateVarsBody(name: ts.Identifier): ts.ExpressionStatement {
293 return ts.factory.createExpressionStatement(ts.factory.createCallExpression(
294 ts.factory.createPropertyAccessExpression(
295 ts.factory.createPropertyAccessExpression(
296 ts.factory.createThis(),
297 ts.factory.createIdentifier("__"+name.escapedText.toString())
299 ts.factory.createIdentifier(RESERT)
302 [ts.factory.createPropertyAccessExpression(
303 ts.factory.createIdentifier(COMPONENT_CONSTRUCTOR_PARAMS),
309 function createControllerSet(node: ts.PropertyDeclaration, componentName: ts.Identifier,
310 name: ts.Identifier, checkController: ControllerType): ts.MethodDeclaration {
314 return ts.factory.createMethodDeclaration(undefined, undefined, undefined,
315 ts.factory.createIdentifier(SET_CONTROLLER_METHOD), undefined, undefined,
316 [ts.factory.createParameterDeclaration(undefined, undefined, undefined,
317 ts.factory.createIdentifier(SET_CONTROLLER_CTR), undefined,
318 ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(SET_CONTROLLER_CTR_TYPE),
319 undefined), undefined)], undefined, ts.factory.createBlock(
320 [ts.factory.createExpressionStatement(ts.factory.createBinaryExpression(
321 ts.factory.createPropertyAccessExpression(ts.factory.createThis(), name),
322 ts.factory.createToken(ts.SyntaxKind.EqualsToken),
323 ts.factory.createIdentifier(SET_CONTROLLER_CTR)))], true));
327 function processPropertyNodeDecorator(parentName: ts.Identifier, node: ts.PropertyDeclaration,
328 updateResult: UpdateResult, ctorNode: ts.ConstructorDeclaration, name: ts.Identifier,
329 watchMap: Map<string, ts.Node>, log: LogInfo[], program: ts.Program,
330 context: ts.TransformationContext, hasPreview: boolean, interfaceNode: ts.InterfaceDeclaration):
379 function processStateDecorators(node: ts.PropertyDeclaration, decorator: string,
380 updateResult: UpdateResult, ctorNode: ts.ConstructorDeclaration, log: LogInfo[],
381 program: ts.Program, context: ts.TransformationContext, hasPreview:boolean,
382 interfaceNode: ts.InterfaceDeclaration): void {
383 const name: ts.Identifier = node.name as ts.Identifier;
385 const updateState: ts.Statement[] = [];
386 const variableInitStatement: ts.Statement =
413 function createPurgeVariableDepStatement(variableWithUnderLink: string): ts.Statement {
414 return ts.factory.createExpressionStatement(
415 ts.factory.createCallExpression(
416 ts.factory.createPropertyAccessExpression(
417 ts.factory.createPropertyAccessExpression(
418 ts.factory.createThis(),
419 ts.factory.createIdentifier(variableWithUnderLink)
421 ts.factory.createIdentifier(PURGEDEPENDENCYONELMTID)
424 [ts.factory.createIdentifier(RMELMTID)]
429 function processWatch(node: ts.PropertyDeclaration, decorator: ts.Decorator,
430 watchMap: Map<string, ts.Node>, log: LogInfo[]): void {
433 if (decorator.expression && ts.isCallExpression(decorator.expression) &&
436 const argument: ts.Node = decorator.expression.arguments[0];
437 if (ts.isStringLiteral(argument)) {
447 } else if (ts.isIdentifier(decorator.expression.arguments[0])) {
449 … const propertyNode: ts.PropertyAccessExpression = createPropertyAccessExpressionWithThis(content);
453 } else if (ts.isPropertyAccessExpression(decorator.expression.arguments[0])) {
463 function createVariableInitStatement(node: ts.PropertyDeclaration, decorator: string,
464 log: LogInfo[], program: ts.Program, context: ts.TransformationContext, hasPreview: boolean,
465 interfaceNode: ts.InterfaceDeclaration): ts.Statement {
466 const name: ts.Identifier = node.name as ts.Identifier;
467 let type: ts.TypeNode;
468 let updateState: ts.ExpressionStatement;
509 members.push(ts.factory.createPropertySignature(undefined, name,
510 ts.factory.createToken(ts.SyntaxKind.QuestionToken), type));
511 interfaceNode = ts.factory.updateInterfaceDeclaration(interfaceNode, undefined,
517 function wrongDecoratorInPreview(node: ts.PropertyDeclaration, decorator: string,
529 function createUpdateParams(name: ts.Identifier, decorator: string,
530 localInitializationNode: ts.PropertyDeclaration = undefined): ts.Statement {
531 let updateParamsNode: ts.Statement;
559 function createStateVarsParams(name: ts.Identifier, decorator: string): ts.Statement {
560 let updateParamsNode: ts.Statement;
569 function createUpdateParamsWithIf(name: ts.Identifier, isProp: boolean = false,
570 initializeNode: ts.Expression = undefined): ts.IfStatement {
571 return ts.factory.createIfStatement(ts.factory.createBinaryExpression(
572 ts.factory.createPropertyAccessExpression(
573 ts.factory.createIdentifier(CREATE_CONSTRUCTOR_PARAMS),
574 ts.factory.createIdentifier(name.escapedText.toString())),
575 isProp ? ts.factory.createToken(ts.SyntaxKind.EqualsEqualsEqualsToken) :
576 ts.factory.createToken(ts.SyntaxKind.ExclamationEqualsEqualsToken),
577 ts.factory.createIdentifier(COMPONENT_CONSTRUCTOR_UNDEFINED)),
578 isProp ? ts.factory.createBlock([createUpdateParamsWithSet(name, true, initializeNode)]) :
579 ts.factory.createBlock([
583 function createUpdateParamsWithoutIf(name: ts.Identifier): ts.ExpressionStatement {
584 return ts.factory.createExpressionStatement(ts.factory.createBinaryExpression(
586 ts.factory.createToken(ts.SyntaxKind.EqualsToken),
590 function createUpdateParamsWithSet(name: ts.Identifier, hasElse: boolean = false,
591 initializeNode: ts.Expression = undefined): ts.ExpressionStatement {
592 return ts.factory.createExpressionStatement(ts.factory.createCallExpression(
593ts.factory.createPropertyAccessExpression(createPropertyAccessExpressionWithThis(`__${name.getText…
594 ts.factory.createIdentifier(CREATE_SET_METHOD)), undefined,
598 function updateNormalProperty(node: ts.PropertyDeclaration, name: ts.Identifier,
599 log: LogInfo[], context: ts.TransformationContext): ts.ExpressionStatement {
600 const init: ts.Expression =
601 ts.visitNode(node.initializer, visitDialogController);
602 function visitDialogController(node: ts.Node): ts.Node {
604 node = createReference(node as ts.PropertyAssignment, log);
606 return ts.visitEachChild(node, visitDialogController, context);
608 return ts.factory.createExpressionStatement(ts.factory.createBinaryExpression(
610 ts.factory.createToken(ts.SyntaxKind.EqualsToken), init ||
611 ts.factory.createIdentifier(COMPONENT_CONSTRUCTOR_UNDEFINED)));
614 function updateObservedProperty(item: ts.PropertyDeclaration, name: ts.Identifier,
615 type: ts.TypeNode, program: ts.Program): ts.ExpressionStatement {
616 return ts.factory.createExpressionStatement(ts.factory.createBinaryExpression(
618 ts.factory.createToken(ts.SyntaxKind.EqualsToken), ts.factory.createNewExpression(
619 ts.factory.createIdentifier(isSimpleType(type, program) ? OBSERVED_PROPERTY_SIMPLE :
620 OBSERVED_PROPERTY_OBJECT), undefined, [item.initializer, ts.factory.createThis(),
621 ts.factory.createStringLiteral(name.escapedText.toString())])));
624 function updateSynchedPropertyTwoWay(nameIdentifier: ts.Identifier, type: ts.TypeNode,
625 program: ts.Program): ts.ExpressionStatement {
633 function updateSynchedPropertyOneWay(nameIdentifier: ts.Identifier, type: ts.TypeNode,
634 decoractor: string, log: LogInfo[], program: ts.Program): ts.ExpressionStatement {
644 function updateStoragePropAndLinkProperty(node: ts.PropertyDeclaration, name: ts.Identifier,
645 decorator: string, log: LogInfo[]): ts.ExpressionStatement {
649 const storageValue: ts.Expression[] = [
652 ts.factory.createThis(), constant
653 ts.factory.createStringLiteral(name.getText())
665 return ts.factory.createExpressionStatement(ts.factory.createBinaryExpression(
667 ts.factory.createToken(ts.SyntaxKind.EqualsToken), ts.factory.createCallExpression(
668 ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier(storageFuncName),
669 ts.factory.createIdentifier(setFuncName)), undefined, storageValue)));
675 function getDecoratorKey(node: ts.PropertyDeclaration): string {
678 const keyNameNode: ts.Node = node.decorators[0].expression.arguments[0];
679 if (ts.isIdentifier(keyNameNode)) {
682 } else if (ts.isStringLiteral(keyNameNode)) {
688 function updateSynchedPropertyNesedObject(nameIdentifier: ts.Identifier,
689 type: ts.TypeNode, decoractor: string, log: LogInfo[]): ts.ExpressionStatement {
698 function updateConsumeProperty(node: ts.PropertyDeclaration,
699 nameIdentifier: ts.Identifier): ts.ExpressionStatement {
707 return ts.factory.createExpressionStatement(ts.factory.createBinaryExpression(
709 ts.factory.createToken(ts.SyntaxKind.EqualsToken), ts.factory.createCallExpression(
711ts.factory.createStringLiteral(propertyOrAliasName), ts.factory.createStringLiteral(name)])));
714 function updateBuilderParamProperty(node: ts.PropertyDeclaration,
715 nameIdentifier: ts.Identifier, log: LogInfo[]): ts.ExpressionStatement {
724 return ts.factory.createExpressionStatement(ts.factory.createBinaryExpression(
725 createPropertyAccessExpressionWithThis(name), ts.factory.createToken(ts.SyntaxKind.EqualsToken),
726 node.initializer || ts.factory.createIdentifier(COMPONENT_CONSTRUCTOR_UNDEFINED)
730 function judgeBuilderParamAssignedByBuilder(node: ts.PropertyDeclaration): boolean {
731 return node.initializer && !(node.initializer && (ts.isIdentifier(node.initializer) &&
733 ts.isPropertyAccessExpression(node.initializer) && node.initializer.name &&
734 ts.isIdentifier(node.initializer.name) &&
738 function createCustomComponentBuilderArrowFunction(parent: ts.PropertyDeclaration,
739 jsDialog: ts.Identifier, newExp: ts.Expression): ts.ArrowFunction {
740 return ts.factory.createArrowFunction(undefined, undefined, [], undefined,
741 ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), ts.factory.createBlock([
742 ts.factory.createVariableStatement(undefined, ts.factory.createVariableDeclarationList(
743 [ts.factory.createVariableDeclaration(jsDialog, undefined, undefined, newExp)],
744 ts.NodeFlags.Let)), ts.factory.createExpressionStatement(ts.factory.createCallExpression(
745 ts.factory.createPropertyAccessExpression(jsDialog,
746 ts.factory.createIdentifier(SET_CONTROLLER_METHOD)), undefined,
747 [ts.factory.createPropertyAccessExpression(ts.factory.createThis(),
748 parent.name as ts.Identifier)])), ts.factory.createExpressionStatement(
752 export function createViewCreate(node: ts.NewExpression | ts.Identifier): ts.CallExpression {
754 return createFunction(ts.factory.createIdentifier(BASE_COMPONENT_NAME_PU),
755 ts.factory.createIdentifier(COMPONENT_CREATE_FUNCTION), ts.factory.createNodeArray([node]));
757 return createFunction(ts.factory.createIdentifier(BASE_COMPONENT_NAME),
758 ts.factory.createIdentifier(COMPONENT_CREATE_FUNCTION), ts.factory.createNodeArray([node]));
761 export function createCustomComponentNewExpression(node: ts.CallExpression, name: string,
763 isCutomDialog: boolean = false): ts.NewExpression {
764 const newNode: ts.NewExpression = ts.factory.createNewExpression(node.expression,
769 function addCustomComponentId(node: ts.NewExpression, componentName: string,
771 isCutomDialog: boolean = false): ts.NewExpression {
776 let argumentsArray: ts.Expression[];
782 argumentsArray = [ts.factory.createObjectLiteralExpression([], true)];
786 argumentsArray.unshift(isBuilder ? ts.factory.createBinaryExpression(
787ts.factory.createStringLiteral(path.basename(transformLog.sourceFile.fileName, EXTNAME_ETS) + '_'),
788ts.factory.createToken(ts.SyntaxKind.PlusToken), ts.factory.createIdentifier(_GENERATE_ID)) :
789 ts.factory.createStringLiteral(componentInfo.id.toString()),
790 isBuilder ? parentConditionalExpression() : ts.factory.createThis());
792 … argumentsArray.unshift(isGlobalBuilder ? parentConditionalExpression() : ts.factory.createThis());
793 argumentsArray.push(ts.factory.createIdentifier(COMPONENT_IF_UNDEFINED),
794 isCutomDialog ? ts.factory.createPrefixUnaryExpression(
795 ts.SyntaxKind.MinusToken,
796 ts.factory.createNumericLiteral('1')) : ts.factory.createIdentifier(ELMTID),
797 ts.factory.createIdentifier(COMPONENT_PARAMS_LAMBDA_FUNCTION));
800 ts.factory.updateNewExpression(node, node.expression, node.typeArguments, argumentsArray);
803 ts.factory.updateNewExpression(node, node.expression, node.typeArguments, argumentsArray);
810 parameterNode: ts.Expression): ts.ExpressionStatement {
811 return ts.factory.createExpressionStatement(ts.factory.createBinaryExpression(
813 ts.factory.createToken(ts.SyntaxKind.EqualsToken), ts.factory.createNewExpression(
814 ts.factory.createIdentifier(functionName), undefined, [parameterNode, ts.factory.createThis(),
815 ts.factory.createStringLiteral(propertyName)])));
818 function createPropertyAccessExpressionWithParams(propertyName: string): ts.PropertyAccessExpressio…
819 …return ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier(CREATE_CONSTRUCTOR_PA…
820 ts.factory.createIdentifier(propertyName));
823 function createPropertyAccessExpressionWithThis(propertyName: string): ts.PropertyAccessExpression {
824 return ts.factory.createPropertyAccessExpression(ts.factory.createThis(),
825 ts.factory.createIdentifier(propertyName));
828 function addAddProvidedVar(node: ts.PropertyDeclaration, name: ts.Identifier,
829 decoratorName: string, updateState: ts.Statement[]): void {
843 name: ts.Identifier): ts.ExpressionStatement {
844 return ts.factory.createExpressionStatement(ts.factory.createCallExpression(
846 ts.factory.createStringLiteral(propertyOrAliasName),
850 function createGetAccessor(item: ts.Identifier, express: string): ts.GetAccessorDeclaration {
851 const getAccessorStatement: ts.GetAccessorDeclaration =
852 ts.factory.createGetAccessorDeclaration(undefined, undefined, item, [], undefined,
853 ts.factory.createBlock([ts.factory.createReturnStatement(
854 ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(
856 ts.factory.createIdentifier(express)), undefined, []))], true));
860 function createSetAccessor(item: ts.Identifier, express: string, type: ts.TypeNode):
861 ts.SetAccessorDeclaration {
862 const setAccessorStatement: ts.SetAccessorDeclaration =
863 ts.factory.createSetAccessorDeclaration(undefined, undefined, item,
864 [ts.factory.createParameterDeclaration(undefined, undefined, undefined,
865 ts.factory.createIdentifier(CREATE_NEWVALUE_IDENTIFIER), undefined, type,
866 undefined)], ts.factory.createBlock([ts.factory.createExpressionStatement(
867 ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(
869 ts.factory.createIdentifier(express)), undefined,
870 [ts.factory.createIdentifier(CREATE_NEWVALUE_IDENTIFIER)]))], true));
874 function isForbiddenUseStateType(typeNode: ts.TypeNode): boolean {
875 if (ts.isTypeReferenceNode(typeNode) && ts.isIdentifier(typeNode.typeName) &&
882 export function isSimpleType(typeNode: ts.TypeNode, program: ts.Program, log?: LogInfo[]): boolean {
883 typeNode = typeNode || ts.factory.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword);
884 let checker: ts.TypeChecker;
895 function getDeclarationType(typeNode: ts.TypeNode, checker: ts.TypeChecker, log: LogInfo[]): boolea…
899 if (ts.isTypeReferenceNode(typeNode) && typeNode.typeName && ts.isIdentifier(typeNode.typeName) &&
904 const type: ts.Type = checker.getTypeFromTypeNode(typeNode);
943 function isObservedClassType(type: ts.TypeNode): boolean {
946 } else if (ts.isUnionTypeNode(type) && type.types) {
947 const types: ts.NodeArray<ts.TypeNode> = type.types;
958 function judgmentTypedeclaration(type: ts.TypeNode): boolean {
959 return ts.isTypeReferenceNode(type) && type.typeName && ts.isIdentifier(type.typeName);
962 function validateAppStorageDecoractorsNonSingleKey(node: ts.PropertyDeclaration,
964 if (ts.isIdentifier(node.decorators[0].expression)) {
966 } else if (ts.isCallExpression(node.decorators[0].expression) &&
967 ts.isIdentifier(node.decorators[0].expression.expression)) {
972 function isSingleKey(node: ts.PropertyDeclaration): boolean {
973 if (ts.isCallExpression(node.decorators[0].expression) &&
976 (ts.isIdentifier(node.decorators[0].expression.arguments[0]) ||
977 ts.isStringLiteral(node.decorators[0].expression.arguments[0]))) {
982 function validateMultiDecorators(name: ts.Identifier, log: LogInfo[]): void {
990 function validateDecoratorNonSingleKey(decoratorsIdentifier: ts.Identifier,
999 function validatePropertyNonDefaultValue(propertyName: ts.Identifier, decorator: string,
1008 function validatePropertyDefaultValue(propertyName: ts.Identifier, decorator: string,
1017 function validatePropertyNonType(propertyName: ts.Identifier, log: LogInfo[]): void {
1025 function validateNonSimpleType(propertyName: ts.Identifier, decorator: string,
1035 function validateNonObservedClassType(propertyName: ts.Identifier, decorator: string,
1045 function validateHasIllegalQuestionToken(propertyName: ts.Identifier, decorator: string,
1054 function validateHasIllegalDecoratorInEntry(parentName: ts.Identifier, propertyName: ts.Identifier,
1064 function validateForbiddenUseStateType(propertyName: ts.Identifier, decorator: string, type: string,
1073 function validateDuplicateDecorator(decorator: ts.Decorator, log: LogInfo[]): void {
1082 function validateWatchDecorator(propertyName: ts.Identifier, length: number, log: LogInfo[]): boole…
1102 function validateVariableType(typeNode: ts.TypeNode, log: LogInfo[]): void {
1112 function updateObservedPropertyPU(item: ts.PropertyDeclaration, name: ts.Identifier,
1113 type: ts.TypeNode, program: ts.Program): ts.ExpressionStatement {
1114 return ts.factory.createExpressionStatement(ts.factory.createBinaryExpression(
1116 ts.factory.createToken(ts.SyntaxKind.EqualsToken), ts.factory.createNewExpression(
1117 ts.factory.createIdentifier(isSimpleType(type, program) ? OBSERVED_PROPERTY_SIMPLE_PU :
1118 OBSERVED_PROPERTY_OBJECT_PU), undefined, [item.initializer, ts.factory.createThis(),
1119 ts.factory.createStringLiteral(name.escapedText.toString())])));
1122 function updateSynchedPropertyTwoWayPU(nameIdentifier: ts.Identifier, type: ts.TypeNode,
1123 program: ts.Program): ts.ExpressionStatement {
1131 function updateSynchedPropertyOneWayPU(nameIdentifier: ts.Identifier, type: ts.TypeNode,
1132 decoractor: string, log: LogInfo[], program: ts.Program): ts.ExpressionStatement {
1143 function updateSynchedPropertyNesedObjectPU(nameIdentifier: ts.Identifier,
1144 type: ts.TypeNode, decoractor: string, log: LogInfo[]): ts.ExpressionStatement {
1153 function validateCustomDecorator(decorators: ts.NodeArray<ts.Decorator>, log: LogInfo[]): boolean {
1156 let innerDecorator: ts.Decorator;
1158 let decorator: ts.Decorator = decorators[i];
1179 function validatePropDecorator(decorators: ts.NodeArray<ts.Decorator>): boolean {
1181 let decorator: ts.Decorator = decorators[i];