From e5fce042cab9bf42c923d68f6c5efea52dc8392a Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Fri, 10 Jul 2015 11:42:03 -0700 Subject: [PATCH] Added location parameter to argument list for create functions --- scripts/processTypes.ts | 14 +- src/compiler/factory.generated.ts | 610 +++++++++++++++--------------- src/compiler/factory.ts | 12 +- 3 files changed, 321 insertions(+), 315 deletions(-) diff --git a/scripts/processTypes.ts b/scripts/processTypes.ts index 36e9bae0bc7..251e5dc006d 100644 --- a/scripts/processTypes.ts +++ b/scripts/processTypes.ts @@ -825,29 +825,21 @@ function generate(outputFile: string) { function writeCreateFunction(syntaxNode: SyntaxNode) { writer.write(`export function create${syntaxNode.kindName}(`); - let first = true; for (let member of syntaxNode.members) { - if (!first) { - writer.write(`, `); - } - else { - first = false; - } - let type = member.isNodeArray ? `Array<${member.elementTypeName}>` : member.isModifiersArray ? `Array` : member.typeName; - writer.write(`${member.paramName}?: ${type}`); + writer.write(`${member.paramName}?: ${type}, `); } - writer.write(`): ${syntaxNode.typeName} {`); + writer.write(`location?: TextRange): ${syntaxNode.typeName} {`); writer.writeLine(); writer.increaseIndent(); if (syntaxNode.members.length) { - writer.write(`let node = createNode<${syntaxNode.typeName}>(SyntaxKind.${syntaxNode.kindName});`); + writer.write(`let node = createNode<${syntaxNode.typeName}>(SyntaxKind.${syntaxNode.kindName}, location);`); writer.writeLine(); if (syntaxNode.members.length > 1) { writer.write(`if (arguments.length) {`); diff --git a/src/compiler/factory.generated.ts b/src/compiler/factory.generated.ts index 0be62934883..b73527e220e 100644 --- a/src/compiler/factory.generated.ts +++ b/src/compiler/factory.generated.ts @@ -3,51 +3,51 @@ /// namespace ts { export namespace factory { - export function createNumericLiteral(text?: string): LiteralExpression { - let node = createNode(SyntaxKind.NumericLiteral); + export function createNumericLiteral(text?: string, location?: TextRange): LiteralExpression { + let node = createNode(SyntaxKind.NumericLiteral, location); node.text = text; return node; } - export function createStringLiteral(text?: string): StringLiteral { - let node = createNode(SyntaxKind.StringLiteral); + export function createStringLiteral(text?: string, location?: TextRange): StringLiteral { + let node = createNode(SyntaxKind.StringLiteral, location); node.text = text; return node; } - export function createRegularExpressionLiteral(text?: string): LiteralExpression { - let node = createNode(SyntaxKind.RegularExpressionLiteral); + export function createRegularExpressionLiteral(text?: string, location?: TextRange): LiteralExpression { + let node = createNode(SyntaxKind.RegularExpressionLiteral, location); node.text = text; return node; } - export function createNoSubstitutionTemplateLiteral(text?: string): LiteralExpression { - let node = createNode(SyntaxKind.NoSubstitutionTemplateLiteral); + export function createNoSubstitutionTemplateLiteral(text?: string, location?: TextRange): LiteralExpression { + let node = createNode(SyntaxKind.NoSubstitutionTemplateLiteral, location); node.text = text; return node; } - export function createTemplateHead(text?: string): LiteralExpression { - let node = createNode(SyntaxKind.TemplateHead); + export function createTemplateHead(text?: string, location?: TextRange): LiteralExpression { + let node = createNode(SyntaxKind.TemplateHead, location); node.text = text; return node; } - export function createTemplateMiddle(text?: string): LiteralExpression { - let node = createNode(SyntaxKind.TemplateMiddle); + export function createTemplateMiddle(text?: string, location?: TextRange): LiteralExpression { + let node = createNode(SyntaxKind.TemplateMiddle, location); node.text = text; return node; } - export function createTemplateTail(text?: string): LiteralExpression { - let node = createNode(SyntaxKind.TemplateTail); + export function createTemplateTail(text?: string, location?: TextRange): LiteralExpression { + let node = createNode(SyntaxKind.TemplateTail, location); node.text = text; return node; } - export function createIdentifier(text?: string, originalKeywordKind?: SyntaxKind): Identifier { - let node = createNode(SyntaxKind.Identifier); + export function createIdentifier(text?: string, originalKeywordKind?: SyntaxKind, location?: TextRange): Identifier { + let node = createNode(SyntaxKind.Identifier, location); if (arguments.length) { node.text = text; node.originalKeywordKind = originalKeywordKind; } return node; } - export function createQualifiedName(left?: EntityName, right?: Identifier): QualifiedName { - let node = createNode(SyntaxKind.QualifiedName); + export function createQualifiedName(left?: EntityName, right?: Identifier, location?: TextRange): QualifiedName { + let node = createNode(SyntaxKind.QualifiedName, location); if (arguments.length) { node.left = left; node.right = right; @@ -61,8 +61,8 @@ namespace ts { } return node; } - export function createComputedPropertyName(expression?: Expression): ComputedPropertyName { - let node = createNode(SyntaxKind.ComputedPropertyName); + export function createComputedPropertyName(expression?: Expression, location?: TextRange): ComputedPropertyName { + let node = createNode(SyntaxKind.ComputedPropertyName, location); node.expression = expression; return node; } @@ -73,8 +73,9 @@ namespace ts { } return node; } - export function createTypeParameter(name?: Identifier, constraint?: TypeNode, expression?: Expression): TypeParameterDeclaration { - let node = createNode(SyntaxKind.TypeParameter); + export function createTypeParameter(name?: Identifier, constraint?: TypeNode, expression?: Expression, + location?: TextRange): TypeParameterDeclaration { + let node = createNode(SyntaxKind.TypeParameter, location); if (arguments.length) { node.name = name; node.constraint = constraint; @@ -91,8 +92,9 @@ namespace ts { return node; } export function createParameter(decorators?: Array, modifiers?: Array, dotDotDotToken?: Node, - name?: Identifier | BindingPattern, questionToken?: Node, type?: TypeNode, initializer?: Expression): ParameterDeclaration { - let node = createNode(SyntaxKind.Parameter); + name?: Identifier | BindingPattern, questionToken?: Node, type?: TypeNode, initializer?: Expression, + location?: TextRange): ParameterDeclaration { + let node = createNode(SyntaxKind.Parameter, location); if (arguments.length) { node.decorators = decorators && createNodeArray(decorators) setModifiers(node, modifiers); @@ -113,8 +115,8 @@ namespace ts { } return node; } - export function createDecorator(expression?: LeftHandSideExpression): Decorator { - let node = createNode(SyntaxKind.Decorator); + export function createDecorator(expression?: LeftHandSideExpression, location?: TextRange): Decorator { + let node = createNode(SyntaxKind.Decorator, location); node.expression = expression; return node; } @@ -126,8 +128,8 @@ namespace ts { return node; } export function createPropertySignature(decorators?: Array, modifiers?: Array, name?: DeclarationName, questionToken?: Node, - type?: TypeNode): PropertySignature { - let node = createNode(SyntaxKind.PropertySignature); + type?: TypeNode, location?: TextRange): PropertySignature { + let node = createNode(SyntaxKind.PropertySignature, location); if (arguments.length) { node.decorators = decorators && createNodeArray(decorators) setModifiers(node, modifiers); @@ -146,8 +148,8 @@ namespace ts { return node; } export function createPropertyDeclaration(decorators?: Array, modifiers?: Array, name?: DeclarationName, - questionToken?: Node, type?: TypeNode, initializer?: Expression): PropertyDeclaration { - let node = createNode(SyntaxKind.PropertyDeclaration); + questionToken?: Node, type?: TypeNode, initializer?: Expression, location?: TextRange): PropertyDeclaration { + let node = createNode(SyntaxKind.PropertyDeclaration, location); if (arguments.length) { node.decorators = decorators && createNodeArray(decorators) setModifiers(node, modifiers); @@ -168,8 +170,9 @@ namespace ts { return node; } export function createMethodSignature(decorators?: Array, modifiers?: Array, name?: DeclarationName, questionToken?: Node, - typeParameters?: Array, parameters?: Array, type?: TypeNode): MethodSignature { - let node = createNode(SyntaxKind.MethodSignature); + typeParameters?: Array, parameters?: Array, type?: TypeNode, + location?: TextRange): MethodSignature { + let node = createNode(SyntaxKind.MethodSignature, location); if (arguments.length) { node.decorators = decorators && createNodeArray(decorators) setModifiers(node, modifiers); @@ -191,9 +194,9 @@ namespace ts { return node; } export function createMethodDeclaration(decorators?: Array, modifiers?: Array, name?: DeclarationName, - typeParameters?: Array, parameters?: Array, type?: TypeNode, body?: Block - ): MethodDeclaration { - let node = createNode(SyntaxKind.MethodDeclaration); + typeParameters?: Array, parameters?: Array, type?: TypeNode, body?: Block, + location?: TextRange): MethodDeclaration { + let node = createNode(SyntaxKind.MethodDeclaration, location); if (arguments.length) { node.decorators = decorators && createNodeArray(decorators) setModifiers(node, modifiers); @@ -216,8 +219,8 @@ namespace ts { return node; } export function createConstructor(decorators?: Array, modifiers?: Array, parameters?: Array, - type?: TypeNode, body?: Block): ConstructorDeclaration { - let node = createNode(SyntaxKind.Constructor); + type?: TypeNode, body?: Block, location?: TextRange): ConstructorDeclaration { + let node = createNode(SyntaxKind.Constructor, location); if (arguments.length) { node.decorators = decorators && createNodeArray(decorators) setModifiers(node, modifiers); @@ -237,8 +240,8 @@ namespace ts { return node; } export function createGetAccessor(decorators?: Array, modifiers?: Array, name?: DeclarationName, - parameters?: Array, type?: TypeNode, body?: Block): GetAccessorDeclaration { - let node = createNode(SyntaxKind.GetAccessor); + parameters?: Array, type?: TypeNode, body?: Block, location?: TextRange): GetAccessorDeclaration { + let node = createNode(SyntaxKind.GetAccessor, location); if (arguments.length) { node.decorators = decorators && createNodeArray(decorators) setModifiers(node, modifiers); @@ -259,8 +262,8 @@ namespace ts { return node; } export function createSetAccessor(decorators?: Array, modifiers?: Array, name?: DeclarationName, - parameters?: Array, type?: TypeNode, body?: Block): SetAccessorDeclaration { - let node = createNode(SyntaxKind.SetAccessor); + parameters?: Array, type?: TypeNode, body?: Block, location?: TextRange): SetAccessorDeclaration { + let node = createNode(SyntaxKind.SetAccessor, location); if (arguments.length) { node.decorators = decorators && createNodeArray(decorators) setModifiers(node, modifiers); @@ -281,8 +284,8 @@ namespace ts { return node; } export function createCallSignature(typeParameters?: Array, parameters?: Array, - type?: TypeNode): CallSignatureDeclaration { - let node = createNode(SyntaxKind.CallSignature); + type?: TypeNode, location?: TextRange): CallSignatureDeclaration { + let node = createNode(SyntaxKind.CallSignature, location); if (arguments.length) { node.typeParameters = typeParameters && createNodeArray(typeParameters) node.parameters = parameters && createNodeArray(parameters) @@ -299,8 +302,8 @@ namespace ts { return node; } export function createConstructSignature(typeParameters?: Array, parameters?: Array, - type?: TypeNode): ConstructSignatureDeclaration { - let node = createNode(SyntaxKind.ConstructSignature); + type?: TypeNode, location?: TextRange): ConstructSignatureDeclaration { + let node = createNode(SyntaxKind.ConstructSignature, location); if (arguments.length) { node.typeParameters = typeParameters && createNodeArray(typeParameters) node.parameters = parameters && createNodeArray(parameters) @@ -317,8 +320,8 @@ namespace ts { return node; } export function createIndexSignature(decorators?: Array, modifiers?: Array, parameters?: Array, - type?: TypeNode): IndexSignatureDeclaration { - let node = createNode(SyntaxKind.IndexSignature); + type?: TypeNode, location?: TextRange): IndexSignatureDeclaration { + let node = createNode(SyntaxKind.IndexSignature, location); if (arguments.length) { node.decorators = decorators && createNodeArray(decorators) setModifiers(node, modifiers); @@ -335,8 +338,8 @@ namespace ts { } return node; } - export function createTypePredicate(parameterName?: Identifier, type?: TypeNode): TypePredicateNode { - let node = createNode(SyntaxKind.TypePredicate); + export function createTypePredicate(parameterName?: Identifier, type?: TypeNode, location?: TextRange): TypePredicateNode { + let node = createNode(SyntaxKind.TypePredicate, location); if (arguments.length) { node.parameterName = parameterName; node.type = type; @@ -350,8 +353,8 @@ namespace ts { } return node; } - export function createTypeReference(typeName?: EntityName, typeArguments?: Array): TypeReferenceNode { - let node = createNode(SyntaxKind.TypeReference); + export function createTypeReference(typeName?: EntityName, typeArguments?: Array, location?: TextRange): TypeReferenceNode { + let node = createNode(SyntaxKind.TypeReference, location); if (arguments.length) { node.typeName = typeName; node.typeArguments = typeArguments && createNodeArray(typeArguments) @@ -366,8 +369,8 @@ namespace ts { return node; } export function createFunctionType(typeParameters?: Array, parameters?: Array, - type?: TypeNode): FunctionTypeNode { - let node = createNode(SyntaxKind.FunctionType); + type?: TypeNode, location?: TextRange): FunctionTypeNode { + let node = createNode(SyntaxKind.FunctionType, location); if (arguments.length) { node.typeParameters = typeParameters && createNodeArray(typeParameters) node.parameters = parameters && createNodeArray(parameters) @@ -384,8 +387,8 @@ namespace ts { return node; } export function createConstructorType(typeParameters?: Array, parameters?: Array, - type?: TypeNode): ConstructorTypeNode { - let node = createNode(SyntaxKind.ConstructorType); + type?: TypeNode, location?: TextRange): ConstructorTypeNode { + let node = createNode(SyntaxKind.ConstructorType, location); if (arguments.length) { node.typeParameters = typeParameters && createNodeArray(typeParameters) node.parameters = parameters && createNodeArray(parameters) @@ -401,8 +404,8 @@ namespace ts { } return node; } - export function createTypeQuery(exprName?: EntityName): TypeQueryNode { - let node = createNode(SyntaxKind.TypeQuery); + export function createTypeQuery(exprName?: EntityName, location?: TextRange): TypeQueryNode { + let node = createNode(SyntaxKind.TypeQuery, location); node.exprName = exprName; return node; } @@ -413,8 +416,8 @@ namespace ts { } return node; } - export function createTypeLiteral(members?: Array): TypeLiteralNode { - let node = createNode(SyntaxKind.TypeLiteral); + export function createTypeLiteral(members?: Array, location?: TextRange): TypeLiteralNode { + let node = createNode(SyntaxKind.TypeLiteral, location); node.members = members && createNodeArray(members) return node; } @@ -425,8 +428,8 @@ namespace ts { } return node; } - export function createArrayType(elementType?: TypeNode): ArrayTypeNode { - let node = createNode(SyntaxKind.ArrayType); + export function createArrayType(elementType?: TypeNode, location?: TextRange): ArrayTypeNode { + let node = createNode(SyntaxKind.ArrayType, location); node.elementType = elementType; return node; } @@ -437,8 +440,8 @@ namespace ts { } return node; } - export function createTupleType(elementTypes?: Array): TupleTypeNode { - let node = createNode(SyntaxKind.TupleType); + export function createTupleType(elementTypes?: Array, location?: TextRange): TupleTypeNode { + let node = createNode(SyntaxKind.TupleType, location); node.elementTypes = elementTypes && createNodeArray(elementTypes) return node; } @@ -449,8 +452,8 @@ namespace ts { } return node; } - export function createUnionType(types?: Array): UnionTypeNode { - let node = createNode(SyntaxKind.UnionType); + export function createUnionType(types?: Array, location?: TextRange): UnionTypeNode { + let node = createNode(SyntaxKind.UnionType, location); node.types = types && createNodeArray(types) return node; } @@ -461,8 +464,8 @@ namespace ts { } return node; } - export function createIntersectionType(types?: Array): IntersectionTypeNode { - let node = createNode(SyntaxKind.IntersectionType); + export function createIntersectionType(types?: Array, location?: TextRange): IntersectionTypeNode { + let node = createNode(SyntaxKind.IntersectionType, location); node.types = types && createNodeArray(types) return node; } @@ -473,8 +476,8 @@ namespace ts { } return node; } - export function createParenthesizedType(type?: TypeNode): ParenthesizedTypeNode { - let node = createNode(SyntaxKind.ParenthesizedType); + export function createParenthesizedType(type?: TypeNode, location?: TextRange): ParenthesizedTypeNode { + let node = createNode(SyntaxKind.ParenthesizedType, location); node.type = type; return node; } @@ -485,8 +488,8 @@ namespace ts { } return node; } - export function createObjectBindingPattern(elements?: Array): ObjectBindingPattern { - let node = createNode(SyntaxKind.ObjectBindingPattern); + export function createObjectBindingPattern(elements?: Array, location?: TextRange): ObjectBindingPattern { + let node = createNode(SyntaxKind.ObjectBindingPattern, location); node.elements = elements && createNodeArray(elements) return node; } @@ -497,8 +500,8 @@ namespace ts { } return node; } - export function createArrayBindingPattern(elements?: Array): ArrayBindingPattern { - let node = createNode(SyntaxKind.ArrayBindingPattern); + export function createArrayBindingPattern(elements?: Array, location?: TextRange): ArrayBindingPattern { + let node = createNode(SyntaxKind.ArrayBindingPattern, location); node.elements = elements && createNodeArray(elements) return node; } @@ -509,9 +512,9 @@ namespace ts { } return node; } - export function createBindingElement(decorators?: Array, modifiers?: Array, propertyName?: Identifier, dotDotDotToken?: Node - , name?: Identifier | BindingPattern, initializer?: Expression): BindingElement { - let node = createNode(SyntaxKind.BindingElement); + export function createBindingElement(decorators?: Array, modifiers?: Array, propertyName?: Identifier, + dotDotDotToken?: Node, name?: Identifier | BindingPattern, initializer?: Expression, location?: TextRange): BindingElement { + let node = createNode(SyntaxKind.BindingElement, location); if (arguments.length) { node.decorators = decorators && createNodeArray(decorators) setModifiers(node, modifiers); @@ -531,8 +534,8 @@ namespace ts { } return node; } - export function createArrayLiteralExpression(elements?: Array): ArrayLiteralExpression { - let node = createNode(SyntaxKind.ArrayLiteralExpression); + export function createArrayLiteralExpression(elements?: Array, location?: TextRange): ArrayLiteralExpression { + let node = createNode(SyntaxKind.ArrayLiteralExpression, location); node.elements = elements && createNodeArray(elements) return node; } @@ -544,8 +547,8 @@ namespace ts { return node; } export function createObjectLiteralExpression(decorators?: Array, modifiers?: Array, - properties?: Array): ObjectLiteralExpression { - let node = createNode(SyntaxKind.ObjectLiteralExpression); + properties?: Array, location?: TextRange): ObjectLiteralExpression { + let node = createNode(SyntaxKind.ObjectLiteralExpression, location); if (arguments.length) { node.decorators = decorators && createNodeArray(decorators) setModifiers(node, modifiers); @@ -561,9 +564,9 @@ namespace ts { } return node; } - export function createPropertyAccessExpression(expression?: LeftHandSideExpression, dotToken?: Node, name?: Identifier - ): PropertyAccessExpression { - let node = createNode(SyntaxKind.PropertyAccessExpression); + export function createPropertyAccessExpression(expression?: LeftHandSideExpression, dotToken?: Node, name?: Identifier, + location?: TextRange): PropertyAccessExpression { + let node = createNode(SyntaxKind.PropertyAccessExpression, location); if (arguments.length) { node.expression = expression; node.dotToken = dotToken; @@ -579,9 +582,9 @@ namespace ts { } return node; } - export function createElementAccessExpression(expression?: LeftHandSideExpression, argumentExpression?: Expression - ): ElementAccessExpression { - let node = createNode(SyntaxKind.ElementAccessExpression); + export function createElementAccessExpression(expression?: LeftHandSideExpression, argumentExpression?: Expression, + location?: TextRange): ElementAccessExpression { + let node = createNode(SyntaxKind.ElementAccessExpression, location); if (arguments.length) { node.expression = expression; node.argumentExpression = argumentExpression; @@ -596,9 +599,9 @@ namespace ts { } return node; } - export function createCallExpression(expression?: LeftHandSideExpression, typeArguments?: Array, _arguments?: Array - ): CallExpression { - let node = createNode(SyntaxKind.CallExpression); + export function createCallExpression(expression?: LeftHandSideExpression, typeArguments?: Array, _arguments?: Array, + location?: TextRange): CallExpression { + let node = createNode(SyntaxKind.CallExpression, location); if (arguments.length) { node.expression = expression; node.typeArguments = typeArguments && createNodeArray(typeArguments) @@ -614,9 +617,9 @@ namespace ts { } return node; } - export function createNewExpression(expression?: LeftHandSideExpression, typeArguments?: Array, _arguments?: Array - ): NewExpression { - let node = createNode(SyntaxKind.NewExpression); + export function createNewExpression(expression?: LeftHandSideExpression, typeArguments?: Array, _arguments?: Array, + location?: TextRange): NewExpression { + let node = createNode(SyntaxKind.NewExpression, location); if (arguments.length) { node.expression = expression; node.typeArguments = typeArguments && createNodeArray(typeArguments) @@ -632,9 +635,9 @@ namespace ts { } return node; } - export function createTaggedTemplateExpression(tag?: LeftHandSideExpression, template?: LiteralExpression | TemplateExpression - ): TaggedTemplateExpression { - let node = createNode(SyntaxKind.TaggedTemplateExpression); + export function createTaggedTemplateExpression(tag?: LeftHandSideExpression, template?: LiteralExpression | TemplateExpression, + location?: TextRange): TaggedTemplateExpression { + let node = createNode(SyntaxKind.TaggedTemplateExpression, location); if (arguments.length) { node.tag = tag; node.template = template; @@ -649,8 +652,8 @@ namespace ts { } return node; } - export function createTypeAssertionExpression(type?: TypeNode, expression?: UnaryExpression): TypeAssertion { - let node = createNode(SyntaxKind.TypeAssertionExpression); + export function createTypeAssertionExpression(type?: TypeNode, expression?: UnaryExpression, location?: TextRange): TypeAssertion { + let node = createNode(SyntaxKind.TypeAssertionExpression, location); if (arguments.length) { node.type = type; node.expression = expression; @@ -664,8 +667,8 @@ namespace ts { } return node; } - export function createParenthesizedExpression(expression?: Expression): ParenthesizedExpression { - let node = createNode(SyntaxKind.ParenthesizedExpression); + export function createParenthesizedExpression(expression?: Expression, location?: TextRange): ParenthesizedExpression { + let node = createNode(SyntaxKind.ParenthesizedExpression, location); node.expression = expression; return node; } @@ -677,9 +680,9 @@ namespace ts { return node; } export function createFunctionExpression(decorators?: Array, modifiers?: Array, asteriskToken?: Node, name?: Identifier, - typeParameters?: Array, parameters?: Array, type?: TypeNode, body?: Block | Expression - ): FunctionExpression { - let node = createNode(SyntaxKind.FunctionExpression); + typeParameters?: Array, parameters?: Array, type?: TypeNode, body?: Block | Expression, + location?: TextRange): FunctionExpression { + let node = createNode(SyntaxKind.FunctionExpression, location); if (arguments.length) { node.decorators = decorators && createNodeArray(decorators) setModifiers(node, modifiers); @@ -703,8 +706,9 @@ namespace ts { return node; } export function createArrowFunction(decorators?: Array, modifiers?: Array, typeParameters?: Array, - parameters?: Array, type?: TypeNode, equalsGreaterThanToken?: Node, body?: Block | Expression): ArrowFunction { - let node = createNode(SyntaxKind.ArrowFunction); + parameters?: Array, type?: TypeNode, equalsGreaterThanToken?: Node, body?: Block | Expression, + location?: TextRange): ArrowFunction { + let node = createNode(SyntaxKind.ArrowFunction, location); if (arguments.length) { node.decorators = decorators && createNodeArray(decorators) setModifiers(node, modifiers); @@ -726,8 +730,8 @@ namespace ts { } return node; } - export function createDeleteExpression(expression?: UnaryExpression): DeleteExpression { - let node = createNode(SyntaxKind.DeleteExpression); + export function createDeleteExpression(expression?: UnaryExpression, location?: TextRange): DeleteExpression { + let node = createNode(SyntaxKind.DeleteExpression, location); node.expression = expression; return node; } @@ -738,8 +742,8 @@ namespace ts { } return node; } - export function createTypeOfExpression(expression?: UnaryExpression): TypeOfExpression { - let node = createNode(SyntaxKind.TypeOfExpression); + export function createTypeOfExpression(expression?: UnaryExpression, location?: TextRange): TypeOfExpression { + let node = createNode(SyntaxKind.TypeOfExpression, location); node.expression = expression; return node; } @@ -750,8 +754,8 @@ namespace ts { } return node; } - export function createVoidExpression(expression?: UnaryExpression): VoidExpression { - let node = createNode(SyntaxKind.VoidExpression); + export function createVoidExpression(expression?: UnaryExpression, location?: TextRange): VoidExpression { + let node = createNode(SyntaxKind.VoidExpression, location); node.expression = expression; return node; } @@ -762,8 +766,8 @@ namespace ts { } return node; } - export function createAwaitExpression(expression?: UnaryExpression): AwaitExpression { - let node = createNode(SyntaxKind.AwaitExpression); + export function createAwaitExpression(expression?: UnaryExpression, location?: TextRange): AwaitExpression { + let node = createNode(SyntaxKind.AwaitExpression, location); node.expression = expression; return node; } @@ -774,8 +778,8 @@ namespace ts { } return node; } - export function createPrefixUnaryExpression(operator?: SyntaxKind, operand?: UnaryExpression): PrefixUnaryExpression { - let node = createNode(SyntaxKind.PrefixUnaryExpression); + export function createPrefixUnaryExpression(operator?: SyntaxKind, operand?: UnaryExpression, location?: TextRange): PrefixUnaryExpression { + let node = createNode(SyntaxKind.PrefixUnaryExpression, location); if (arguments.length) { node.operator = operator; node.operand = operand; @@ -789,8 +793,9 @@ namespace ts { } return node; } - export function createPostfixUnaryExpression(operand?: LeftHandSideExpression, operator?: SyntaxKind): PostfixUnaryExpression { - let node = createNode(SyntaxKind.PostfixUnaryExpression); + export function createPostfixUnaryExpression(operand?: LeftHandSideExpression, operator?: SyntaxKind, + location?: TextRange): PostfixUnaryExpression { + let node = createNode(SyntaxKind.PostfixUnaryExpression, location); if (arguments.length) { node.operand = operand; node.operator = operator; @@ -804,8 +809,8 @@ namespace ts { } return node; } - export function createBinaryExpression(left?: Expression, operatorToken?: Node, right?: Expression): BinaryExpression { - let node = createNode(SyntaxKind.BinaryExpression); + export function createBinaryExpression(left?: Expression, operatorToken?: Node, right?: Expression, location?: TextRange): BinaryExpression { + let node = createNode(SyntaxKind.BinaryExpression, location); if (arguments.length) { node.left = left; node.operatorToken = operatorToken; @@ -821,8 +826,8 @@ namespace ts { return node; } export function createConditionalExpression(condition?: Expression, questionToken?: Node, whenTrue?: Expression, colonToken?: Node, - whenFalse?: Expression): ConditionalExpression { - let node = createNode(SyntaxKind.ConditionalExpression); + whenFalse?: Expression, location?: TextRange): ConditionalExpression { + let node = createNode(SyntaxKind.ConditionalExpression, location); if (arguments.length) { node.condition = condition; node.questionToken = questionToken; @@ -840,8 +845,9 @@ namespace ts { } return node; } - export function createTemplateExpression(head?: LiteralExpression, templateSpans?: Array): TemplateExpression { - let node = createNode(SyntaxKind.TemplateExpression); + export function createTemplateExpression(head?: LiteralExpression, templateSpans?: Array, + location?: TextRange): TemplateExpression { + let node = createNode(SyntaxKind.TemplateExpression, location); if (arguments.length) { node.head = head; node.templateSpans = templateSpans && createNodeArray(templateSpans) @@ -856,8 +862,8 @@ namespace ts { } return node; } - export function createYieldExpression(asteriskToken?: Node, expression?: Expression): YieldExpression { - let node = createNode(SyntaxKind.YieldExpression); + export function createYieldExpression(asteriskToken?: Node, expression?: Expression, location?: TextRange): YieldExpression { + let node = createNode(SyntaxKind.YieldExpression, location); if (arguments.length) { node.asteriskToken = asteriskToken; node.expression = expression; @@ -871,8 +877,8 @@ namespace ts { } return node; } - export function createSpreadElementExpression(expression?: Expression): SpreadElementExpression { - let node = createNode(SyntaxKind.SpreadElementExpression); + export function createSpreadElementExpression(expression?: Expression, location?: TextRange): SpreadElementExpression { + let node = createNode(SyntaxKind.SpreadElementExpression, location); node.expression = expression; return node; } @@ -884,9 +890,9 @@ namespace ts { return node; } export function createClassExpression(decorators?: Array, modifiers?: Array, name?: Identifier, - typeParameters?: Array, heritageClauses?: Array, members?: Array - ): ClassExpression { - let node = createNode(SyntaxKind.ClassExpression); + typeParameters?: Array, heritageClauses?: Array, members?: Array, + location?: TextRange): ClassExpression { + let node = createNode(SyntaxKind.ClassExpression, location); if (arguments.length) { node.decorators = decorators && createNodeArray(decorators) setModifiers(node, modifiers); @@ -907,12 +913,12 @@ namespace ts { } return node; } - export function createOmittedExpression(): Expression { + export function createOmittedExpression(location?: TextRange): Expression { return createNode(SyntaxKind.OmittedExpression); } - export function createExpressionWithTypeArguments(expression?: LeftHandSideExpression, typeArguments?: Array - ): ExpressionWithTypeArguments { - let node = createNode(SyntaxKind.ExpressionWithTypeArguments); + export function createExpressionWithTypeArguments(expression?: LeftHandSideExpression, typeArguments?: Array, + location?: TextRange): ExpressionWithTypeArguments { + let node = createNode(SyntaxKind.ExpressionWithTypeArguments, location); if (arguments.length) { node.expression = expression; node.typeArguments = typeArguments && createNodeArray(typeArguments) @@ -927,8 +933,8 @@ namespace ts { } return node; } - export function createAsExpression(expression?: Expression, type?: TypeNode): AsExpression { - let node = createNode(SyntaxKind.AsExpression); + export function createAsExpression(expression?: Expression, type?: TypeNode, location?: TextRange): AsExpression { + let node = createNode(SyntaxKind.AsExpression, location); if (arguments.length) { node.expression = expression; node.type = type; @@ -942,8 +948,8 @@ namespace ts { } return node; } - export function createTemplateSpan(expression?: Expression, literal?: LiteralExpression): TemplateSpan { - let node = createNode(SyntaxKind.TemplateSpan); + export function createTemplateSpan(expression?: Expression, literal?: LiteralExpression, location?: TextRange): TemplateSpan { + let node = createNode(SyntaxKind.TemplateSpan, location); if (arguments.length) { node.expression = expression; node.literal = literal; @@ -957,11 +963,11 @@ namespace ts { } return node; } - export function createSemicolonClassElement(): SemicolonClassElement { + export function createSemicolonClassElement(location?: TextRange): SemicolonClassElement { return createNode(SyntaxKind.SemicolonClassElement); } - export function createBlock(statements?: Array): Block { - let node = createNode(SyntaxKind.Block); + export function createBlock(statements?: Array, location?: TextRange): Block { + let node = createNode(SyntaxKind.Block, location); node.statements = statements && createNodeArray(statements) return node; } @@ -972,8 +978,8 @@ namespace ts { } return node; } - export function createVariableStatement(declarationList?: VariableDeclarationList): VariableStatement { - let node = createNode(SyntaxKind.VariableStatement); + export function createVariableStatement(declarationList?: VariableDeclarationList, location?: TextRange): VariableStatement { + let node = createNode(SyntaxKind.VariableStatement, location); node.declarationList = declarationList; return node; } @@ -984,11 +990,11 @@ namespace ts { } return node; } - export function createEmptyStatement(): Statement { + export function createEmptyStatement(location?: TextRange): Statement { return createNode(SyntaxKind.EmptyStatement); } - export function createExpressionStatement(expression?: Expression): ExpressionStatement { - let node = createNode(SyntaxKind.ExpressionStatement); + export function createExpressionStatement(expression?: Expression, location?: TextRange): ExpressionStatement { + let node = createNode(SyntaxKind.ExpressionStatement, location); node.expression = expression; return node; } @@ -999,8 +1005,9 @@ namespace ts { } return node; } - export function createIfStatement(expression?: Expression, thenStatement?: Statement, elseStatement?: Statement): IfStatement { - let node = createNode(SyntaxKind.IfStatement); + export function createIfStatement(expression?: Expression, thenStatement?: Statement, elseStatement?: Statement, + location?: TextRange): IfStatement { + let node = createNode(SyntaxKind.IfStatement, location); if (arguments.length) { node.expression = expression; node.thenStatement = thenStatement; @@ -1016,8 +1023,8 @@ namespace ts { } return node; } - export function createDoStatement(statement?: Statement, expression?: Expression): DoStatement { - let node = createNode(SyntaxKind.DoStatement); + export function createDoStatement(statement?: Statement, expression?: Expression, location?: TextRange): DoStatement { + let node = createNode(SyntaxKind.DoStatement, location); if (arguments.length) { node.statement = statement; node.expression = expression; @@ -1031,8 +1038,8 @@ namespace ts { } return node; } - export function createWhileStatement(expression?: Expression, statement?: Statement): WhileStatement { - let node = createNode(SyntaxKind.WhileStatement); + export function createWhileStatement(expression?: Expression, statement?: Statement, location?: TextRange): WhileStatement { + let node = createNode(SyntaxKind.WhileStatement, location); if (arguments.length) { node.expression = expression; node.statement = statement; @@ -1047,8 +1054,8 @@ namespace ts { return node; } export function createForStatement(initializer?: VariableDeclarationList | Expression, condition?: Expression, incrementor?: Expression, - statement?: Statement): ForStatement { - let node = createNode(SyntaxKind.ForStatement); + statement?: Statement, location?: TextRange): ForStatement { + let node = createNode(SyntaxKind.ForStatement, location); if (arguments.length) { node.initializer = initializer; node.condition = condition; @@ -1066,9 +1073,9 @@ namespace ts { } return node; } - export function createForInStatement(initializer?: VariableDeclarationList | Expression, expression?: Expression, statement?: Statement - ): ForInStatement { - let node = createNode(SyntaxKind.ForInStatement); + export function createForInStatement(initializer?: VariableDeclarationList | Expression, expression?: Expression, statement?: Statement, + location?: TextRange): ForInStatement { + let node = createNode(SyntaxKind.ForInStatement, location); if (arguments.length) { node.initializer = initializer; node.expression = expression; @@ -1084,9 +1091,9 @@ namespace ts { } return node; } - export function createForOfStatement(initializer?: VariableDeclarationList | Expression, expression?: Expression, statement?: Statement - ): ForOfStatement { - let node = createNode(SyntaxKind.ForOfStatement); + export function createForOfStatement(initializer?: VariableDeclarationList | Expression, expression?: Expression, statement?: Statement, + location?: TextRange): ForOfStatement { + let node = createNode(SyntaxKind.ForOfStatement, location); if (arguments.length) { node.initializer = initializer; node.expression = expression; @@ -1102,8 +1109,8 @@ namespace ts { } return node; } - export function createContinueStatement(label?: Identifier): ContinueStatement { - let node = createNode(SyntaxKind.ContinueStatement); + export function createContinueStatement(label?: Identifier, location?: TextRange): ContinueStatement { + let node = createNode(SyntaxKind.ContinueStatement, location); node.label = label; return node; } @@ -1114,8 +1121,8 @@ namespace ts { } return node; } - export function createBreakStatement(label?: Identifier): BreakStatement { - let node = createNode(SyntaxKind.BreakStatement); + export function createBreakStatement(label?: Identifier, location?: TextRange): BreakStatement { + let node = createNode(SyntaxKind.BreakStatement, location); node.label = label; return node; } @@ -1126,8 +1133,8 @@ namespace ts { } return node; } - export function createReturnStatement(expression?: Expression): ReturnStatement { - let node = createNode(SyntaxKind.ReturnStatement); + export function createReturnStatement(expression?: Expression, location?: TextRange): ReturnStatement { + let node = createNode(SyntaxKind.ReturnStatement, location); node.expression = expression; return node; } @@ -1138,8 +1145,8 @@ namespace ts { } return node; } - export function createWithStatement(expression?: Expression, statement?: Statement): WithStatement { - let node = createNode(SyntaxKind.WithStatement); + export function createWithStatement(expression?: Expression, statement?: Statement, location?: TextRange): WithStatement { + let node = createNode(SyntaxKind.WithStatement, location); if (arguments.length) { node.expression = expression; node.statement = statement; @@ -1153,8 +1160,8 @@ namespace ts { } return node; } - export function createSwitchStatement(expression?: Expression, caseBlock?: CaseBlock): SwitchStatement { - let node = createNode(SyntaxKind.SwitchStatement); + export function createSwitchStatement(expression?: Expression, caseBlock?: CaseBlock, location?: TextRange): SwitchStatement { + let node = createNode(SyntaxKind.SwitchStatement, location); if (arguments.length) { node.expression = expression; node.caseBlock = caseBlock; @@ -1168,8 +1175,8 @@ namespace ts { } return node; } - export function createLabeledStatement(label?: Identifier, statement?: Statement): LabeledStatement { - let node = createNode(SyntaxKind.LabeledStatement); + export function createLabeledStatement(label?: Identifier, statement?: Statement, location?: TextRange): LabeledStatement { + let node = createNode(SyntaxKind.LabeledStatement, location); if (arguments.length) { node.label = label; node.statement = statement; @@ -1183,8 +1190,8 @@ namespace ts { } return node; } - export function createThrowStatement(expression?: Expression): ThrowStatement { - let node = createNode(SyntaxKind.ThrowStatement); + export function createThrowStatement(expression?: Expression, location?: TextRange): ThrowStatement { + let node = createNode(SyntaxKind.ThrowStatement, location); node.expression = expression; return node; } @@ -1195,8 +1202,8 @@ namespace ts { } return node; } - export function createTryStatement(tryBlock?: Block, catchClause?: CatchClause, finallyBlock?: Block): TryStatement { - let node = createNode(SyntaxKind.TryStatement); + export function createTryStatement(tryBlock?: Block, catchClause?: CatchClause, finallyBlock?: Block, location?: TextRange): TryStatement { + let node = createNode(SyntaxKind.TryStatement, location); if (arguments.length) { node.tryBlock = tryBlock; node.catchClause = catchClause; @@ -1211,12 +1218,12 @@ namespace ts { } return node; } - export function createDebuggerStatement(): Statement { + export function createDebuggerStatement(location?: TextRange): Statement { return createNode(SyntaxKind.DebuggerStatement); } export function createVariableDeclaration(decorators?: Array, modifiers?: Array, name?: Identifier | BindingPattern, - type?: TypeNode, initializer?: Expression): VariableDeclaration { - let node = createNode(SyntaxKind.VariableDeclaration); + type?: TypeNode, initializer?: Expression, location?: TextRange): VariableDeclaration { + let node = createNode(SyntaxKind.VariableDeclaration, location); if (arguments.length) { node.decorators = decorators && createNodeArray(decorators) setModifiers(node, modifiers); @@ -1235,8 +1242,8 @@ namespace ts { } return node; } - export function createVariableDeclarationList(declarations?: Array): VariableDeclarationList { - let node = createNode(SyntaxKind.VariableDeclarationList); + export function createVariableDeclarationList(declarations?: Array, location?: TextRange): VariableDeclarationList { + let node = createNode(SyntaxKind.VariableDeclarationList, location); node.declarations = declarations && createNodeArray(declarations) return node; } @@ -1249,9 +1256,9 @@ namespace ts { return node; } export function createFunctionDeclaration(decorators?: Array, modifiers?: Array, asteriskToken?: Node, name?: Identifier, - typeParameters?: Array, parameters?: Array, type?: TypeNode, body?: Block - ): FunctionDeclaration { - let node = createNode(SyntaxKind.FunctionDeclaration); + typeParameters?: Array, parameters?: Array, type?: TypeNode, body?: Block, + location?: TextRange): FunctionDeclaration { + let node = createNode(SyntaxKind.FunctionDeclaration, location); if (arguments.length) { node.decorators = decorators && createNodeArray(decorators) setModifiers(node, modifiers); @@ -1275,9 +1282,9 @@ namespace ts { return node; } export function createClassDeclaration(decorators?: Array, modifiers?: Array, name?: Identifier, - typeParameters?: Array, heritageClauses?: Array, members?: Array - ): ClassDeclaration { - let node = createNode(SyntaxKind.ClassDeclaration); + typeParameters?: Array, heritageClauses?: Array, members?: Array, + location?: TextRange): ClassDeclaration { + let node = createNode(SyntaxKind.ClassDeclaration, location); if (arguments.length) { node.decorators = decorators && createNodeArray(decorators) setModifiers(node, modifiers); @@ -1299,9 +1306,9 @@ namespace ts { return node; } export function createInterfaceDeclaration(decorators?: Array, modifiers?: Array, name?: Identifier, - typeParameters?: Array, heritageClauses?: Array, members?: Array - ): InterfaceDeclaration { - let node = createNode(SyntaxKind.InterfaceDeclaration); + typeParameters?: Array, heritageClauses?: Array, members?: Array, + location?: TextRange): InterfaceDeclaration { + let node = createNode(SyntaxKind.InterfaceDeclaration, location); if (arguments.length) { node.decorators = decorators && createNodeArray(decorators) setModifiers(node, modifiers); @@ -1323,8 +1330,8 @@ namespace ts { return node; } export function createTypeAliasDeclaration(decorators?: Array, modifiers?: Array, name?: Identifier, - typeParameters?: Array, type?: TypeNode): TypeAliasDeclaration { - let node = createNode(SyntaxKind.TypeAliasDeclaration); + typeParameters?: Array, type?: TypeNode, location?: TextRange): TypeAliasDeclaration { + let node = createNode(SyntaxKind.TypeAliasDeclaration, location); if (arguments.length) { node.decorators = decorators && createNodeArray(decorators) setModifiers(node, modifiers); @@ -1343,9 +1350,9 @@ namespace ts { } return node; } - export function createEnumDeclaration(decorators?: Array, modifiers?: Array, name?: Identifier, members?: Array - ): EnumDeclaration { - let node = createNode(SyntaxKind.EnumDeclaration); + export function createEnumDeclaration(decorators?: Array, modifiers?: Array, name?: Identifier, members?: Array, + location?: TextRange): EnumDeclaration { + let node = createNode(SyntaxKind.EnumDeclaration, location); if (arguments.length) { node.decorators = decorators && createNodeArray(decorators) setModifiers(node, modifiers); @@ -1363,8 +1370,8 @@ namespace ts { return node; } export function createModuleDeclaration(decorators?: Array, modifiers?: Array, name?: Identifier | LiteralExpression, - body?: ModuleBlock | ModuleDeclaration): ModuleDeclaration { - let node = createNode(SyntaxKind.ModuleDeclaration); + body?: ModuleBlock | ModuleDeclaration, location?: TextRange): ModuleDeclaration { + let node = createNode(SyntaxKind.ModuleDeclaration, location); if (arguments.length) { node.decorators = decorators && createNodeArray(decorators) setModifiers(node, modifiers); @@ -1381,8 +1388,8 @@ namespace ts { } return node; } - export function createModuleBlock(statements?: Array): ModuleBlock { - let node = createNode(SyntaxKind.ModuleBlock); + export function createModuleBlock(statements?: Array, location?: TextRange): ModuleBlock { + let node = createNode(SyntaxKind.ModuleBlock, location); node.statements = statements && createNodeArray(statements) return node; } @@ -1393,8 +1400,8 @@ namespace ts { } return node; } - export function createCaseBlock(clauses?: Array): CaseBlock { - let node = createNode(SyntaxKind.CaseBlock); + export function createCaseBlock(clauses?: Array, location?: TextRange): CaseBlock { + let node = createNode(SyntaxKind.CaseBlock, location); node.clauses = clauses && createNodeArray(clauses) return node; } @@ -1406,8 +1413,8 @@ namespace ts { return node; } export function createImportEqualsDeclaration(decorators?: Array, modifiers?: Array, name?: Identifier, - moduleReference?: EntityName | ExternalModuleReference): ImportEqualsDeclaration { - let node = createNode(SyntaxKind.ImportEqualsDeclaration); + moduleReference?: EntityName | ExternalModuleReference, location?: TextRange): ImportEqualsDeclaration { + let node = createNode(SyntaxKind.ImportEqualsDeclaration, location); if (arguments.length) { node.decorators = decorators && createNodeArray(decorators) setModifiers(node, modifiers); @@ -1425,8 +1432,8 @@ namespace ts { return node; } export function createImportDeclaration(decorators?: Array, modifiers?: Array, importClause?: ImportClause, - moduleSpecifier?: Expression): ImportDeclaration { - let node = createNode(SyntaxKind.ImportDeclaration); + moduleSpecifier?: Expression, location?: TextRange): ImportDeclaration { + let node = createNode(SyntaxKind.ImportDeclaration, location); if (arguments.length) { node.decorators = decorators && createNodeArray(decorators) setModifiers(node, modifiers); @@ -1444,8 +1451,8 @@ namespace ts { } return node; } - export function createImportClause(name?: Identifier, namedBindings?: NamespaceImport | NamedImports): ImportClause { - let node = createNode(SyntaxKind.ImportClause); + export function createImportClause(name?: Identifier, namedBindings?: NamespaceImport | NamedImports, location?: TextRange): ImportClause { + let node = createNode(SyntaxKind.ImportClause, location); if (arguments.length) { node.name = name; node.namedBindings = namedBindings; @@ -1459,8 +1466,8 @@ namespace ts { } return node; } - export function createNamespaceImport(name?: Identifier): NamespaceImport { - let node = createNode(SyntaxKind.NamespaceImport); + export function createNamespaceImport(name?: Identifier, location?: TextRange): NamespaceImport { + let node = createNode(SyntaxKind.NamespaceImport, location); node.name = name; return node; } @@ -1471,8 +1478,8 @@ namespace ts { } return node; } - export function createNamedImports(elements?: Array): NamedImports { - let node = createNode(SyntaxKind.NamedImports); + export function createNamedImports(elements?: Array, location?: TextRange): NamedImports { + let node = createNode(SyntaxKind.NamedImports, location); node.elements = elements && createNodeArray(elements) return node; } @@ -1483,8 +1490,8 @@ namespace ts { } return node; } - export function createImportSpecifier(propertyName?: Identifier, name?: Identifier): ImportSpecifier { - let node = createNode(SyntaxKind.ImportSpecifier); + export function createImportSpecifier(propertyName?: Identifier, name?: Identifier, location?: TextRange): ImportSpecifier { + let node = createNode(SyntaxKind.ImportSpecifier, location); if (arguments.length) { node.propertyName = propertyName; node.name = name; @@ -1498,8 +1505,9 @@ namespace ts { } return node; } - export function createExportAssignment(decorators?: Array, modifiers?: Array, expression?: Expression): ExportAssignment { - let node = createNode(SyntaxKind.ExportAssignment); + export function createExportAssignment(decorators?: Array, modifiers?: Array, expression?: Expression, + location?: TextRange): ExportAssignment { + let node = createNode(SyntaxKind.ExportAssignment, location); if (arguments.length) { node.decorators = decorators && createNodeArray(decorators) setModifiers(node, modifiers); @@ -1516,8 +1524,8 @@ namespace ts { return node; } export function createExportDeclaration(decorators?: Array, modifiers?: Array, exportClause?: NamedExports, - moduleSpecifier?: Expression): ExportDeclaration { - let node = createNode(SyntaxKind.ExportDeclaration); + moduleSpecifier?: Expression, location?: TextRange): ExportDeclaration { + let node = createNode(SyntaxKind.ExportDeclaration, location); if (arguments.length) { node.decorators = decorators && createNodeArray(decorators) setModifiers(node, modifiers); @@ -1535,8 +1543,8 @@ namespace ts { } return node; } - export function createNamedExports(elements?: Array): NamedExports { - let node = createNode(SyntaxKind.NamedExports); + export function createNamedExports(elements?: Array, location?: TextRange): NamedExports { + let node = createNode(SyntaxKind.NamedExports, location); node.elements = elements && createNodeArray(elements) return node; } @@ -1547,8 +1555,8 @@ namespace ts { } return node; } - export function createExportSpecifier(propertyName?: Identifier, name?: Identifier): ExportSpecifier { - let node = createNode(SyntaxKind.ExportSpecifier); + export function createExportSpecifier(propertyName?: Identifier, name?: Identifier, location?: TextRange): ExportSpecifier { + let node = createNode(SyntaxKind.ExportSpecifier, location); if (arguments.length) { node.propertyName = propertyName; node.name = name; @@ -1562,8 +1570,8 @@ namespace ts { } return node; } - export function createMissingDeclaration(decorators?: Array, modifiers?: Array): MissingDeclaration { - let node = createNode(SyntaxKind.MissingDeclaration); + export function createMissingDeclaration(decorators?: Array, modifiers?: Array, location?: TextRange): MissingDeclaration { + let node = createNode(SyntaxKind.MissingDeclaration, location); if (arguments.length) { node.decorators = decorators && createNodeArray(decorators) setModifiers(node, modifiers); @@ -1578,8 +1586,8 @@ namespace ts { } return node; } - export function createExternalModuleReference(expression?: Expression): ExternalModuleReference { - let node = createNode(SyntaxKind.ExternalModuleReference); + export function createExternalModuleReference(expression?: Expression, location?: TextRange): ExternalModuleReference { + let node = createNode(SyntaxKind.ExternalModuleReference, location); node.expression = expression; return node; } @@ -1590,9 +1598,9 @@ namespace ts { } return node; } - export function createJsxElement(openingElement?: JsxOpeningElement, children?: Array, closingElement?: JsxClosingElement - ): JsxElement { - let node = createNode(SyntaxKind.JsxElement); + export function createJsxElement(openingElement?: JsxOpeningElement, children?: Array, closingElement?: JsxClosingElement, + location?: TextRange): JsxElement { + let node = createNode(SyntaxKind.JsxElement, location); if (arguments.length) { node.openingElement = openingElement; node.children = children && createNodeArray(children) @@ -1608,9 +1616,9 @@ namespace ts { } return node; } - export function createJsxSelfClosingElement(tagName?: EntityName, attributes?: Array - ): JsxSelfClosingElement { - let node = createNode(SyntaxKind.JsxSelfClosingElement); + export function createJsxSelfClosingElement(tagName?: EntityName, attributes?: Array, + location?: TextRange): JsxSelfClosingElement { + let node = createNode(SyntaxKind.JsxSelfClosingElement, location); if (arguments.length) { node.tagName = tagName; node.attributes = attributes && createNodeArray(attributes) @@ -1625,8 +1633,9 @@ namespace ts { } return node; } - export function createJsxOpeningElement(tagName?: EntityName, attributes?: Array): JsxOpeningElement { - let node = createNode(SyntaxKind.JsxOpeningElement); + export function createJsxOpeningElement(tagName?: EntityName, attributes?: Array, + location?: TextRange): JsxOpeningElement { + let node = createNode(SyntaxKind.JsxOpeningElement, location); if (arguments.length) { node.tagName = tagName; node.attributes = attributes && createNodeArray(attributes) @@ -1641,11 +1650,11 @@ namespace ts { } return node; } - export function createJsxText(): JsxText { + export function createJsxText(location?: TextRange): JsxText { return createNode(SyntaxKind.JsxText); } - export function createJsxClosingElement(tagName?: EntityName): JsxClosingElement { - let node = createNode(SyntaxKind.JsxClosingElement); + export function createJsxClosingElement(tagName?: EntityName, location?: TextRange): JsxClosingElement { + let node = createNode(SyntaxKind.JsxClosingElement, location); node.tagName = tagName; return node; } @@ -1656,8 +1665,8 @@ namespace ts { } return node; } - export function createJsxAttribute(name?: Identifier, initializer?: Expression): JsxAttribute { - let node = createNode(SyntaxKind.JsxAttribute); + export function createJsxAttribute(name?: Identifier, initializer?: Expression, location?: TextRange): JsxAttribute { + let node = createNode(SyntaxKind.JsxAttribute, location); if (arguments.length) { node.name = name; node.initializer = initializer; @@ -1671,8 +1680,8 @@ namespace ts { } return node; } - export function createJsxSpreadAttribute(expression?: Expression): JsxSpreadAttribute { - let node = createNode(SyntaxKind.JsxSpreadAttribute); + export function createJsxSpreadAttribute(expression?: Expression, location?: TextRange): JsxSpreadAttribute { + let node = createNode(SyntaxKind.JsxSpreadAttribute, location); node.expression = expression; return node; } @@ -1683,8 +1692,8 @@ namespace ts { } return node; } - export function createJsxExpression(expression?: Expression): JsxExpression { - let node = createNode(SyntaxKind.JsxExpression); + export function createJsxExpression(expression?: Expression, location?: TextRange): JsxExpression { + let node = createNode(SyntaxKind.JsxExpression, location); node.expression = expression; return node; } @@ -1695,8 +1704,8 @@ namespace ts { } return node; } - export function createCaseClause(expression?: Expression, statements?: Array): CaseClause { - let node = createNode(SyntaxKind.CaseClause); + export function createCaseClause(expression?: Expression, statements?: Array, location?: TextRange): CaseClause { + let node = createNode(SyntaxKind.CaseClause, location); if (arguments.length) { node.expression = expression; node.statements = statements && createNodeArray(statements) @@ -1710,8 +1719,8 @@ namespace ts { } return node; } - export function createDefaultClause(statements?: Array): DefaultClause { - let node = createNode(SyntaxKind.DefaultClause); + export function createDefaultClause(statements?: Array, location?: TextRange): DefaultClause { + let node = createNode(SyntaxKind.DefaultClause, location); node.statements = statements && createNodeArray(statements) return node; } @@ -1722,8 +1731,8 @@ namespace ts { } return node; } - export function createHeritageClause(types?: Array): HeritageClause { - let node = createNode(SyntaxKind.HeritageClause); + export function createHeritageClause(types?: Array, location?: TextRange): HeritageClause { + let node = createNode(SyntaxKind.HeritageClause, location); node.types = types && createNodeArray(types) return node; } @@ -1734,8 +1743,8 @@ namespace ts { } return node; } - export function createCatchClause(variableDeclaration?: VariableDeclaration, block?: Block): CatchClause { - let node = createNode(SyntaxKind.CatchClause); + export function createCatchClause(variableDeclaration?: VariableDeclaration, block?: Block, location?: TextRange): CatchClause { + let node = createNode(SyntaxKind.CatchClause, location); if (arguments.length) { node.variableDeclaration = variableDeclaration; node.block = block; @@ -1749,8 +1758,9 @@ namespace ts { } return node; } - export function createPropertyAssignment(name?: DeclarationName, questionToken?: Node, initializer?: Expression): PropertyAssignment { - let node = createNode(SyntaxKind.PropertyAssignment); + export function createPropertyAssignment(name?: DeclarationName, questionToken?: Node, initializer?: Expression, + location?: TextRange): PropertyAssignment { + let node = createNode(SyntaxKind.PropertyAssignment, location); if (arguments.length) { node.name = name; node.questionToken = questionToken; @@ -1765,8 +1775,9 @@ namespace ts { } return node; } - export function createShorthandPropertyAssignment(name?: Identifier, questionToken?: Node): ShorthandPropertyAssignment { - let node = createNode(SyntaxKind.ShorthandPropertyAssignment); + export function createShorthandPropertyAssignment(name?: Identifier, questionToken?: Node, + location?: TextRange): ShorthandPropertyAssignment { + let node = createNode(SyntaxKind.ShorthandPropertyAssignment, location); if (arguments.length) { node.name = name; node.questionToken = questionToken; @@ -1780,8 +1791,8 @@ namespace ts { } return node; } - export function createEnumMember(name?: DeclarationName, initializer?: Expression): EnumMember { - let node = createNode(SyntaxKind.EnumMember); + export function createEnumMember(name?: DeclarationName, initializer?: Expression, location?: TextRange): EnumMember { + let node = createNode(SyntaxKind.EnumMember, location); if (arguments.length) { node.name = name; node.initializer = initializer; @@ -1795,8 +1806,8 @@ namespace ts { } return node; } - export function createJSDocTypeExpression(type?: JSDocType): JSDocTypeExpression { - let node = createNode(SyntaxKind.JSDocTypeExpression); + export function createJSDocTypeExpression(type?: JSDocType, location?: TextRange): JSDocTypeExpression { + let node = createNode(SyntaxKind.JSDocTypeExpression, location); node.type = type; return node; } @@ -1807,14 +1818,14 @@ namespace ts { } return node; } - export function createJSDocAllType(): JSDocAllType { + export function createJSDocAllType(location?: TextRange): JSDocAllType { return createNode(SyntaxKind.JSDocAllType); } - export function createJSDocUnknownType(): JSDocUnknownType { + export function createJSDocUnknownType(location?: TextRange): JSDocUnknownType { return createNode(SyntaxKind.JSDocUnknownType); } - export function createJSDocArrayType(elementType?: JSDocType): JSDocArrayType { - let node = createNode(SyntaxKind.JSDocArrayType); + export function createJSDocArrayType(elementType?: JSDocType, location?: TextRange): JSDocArrayType { + let node = createNode(SyntaxKind.JSDocArrayType, location); node.elementType = elementType; return node; } @@ -1825,8 +1836,8 @@ namespace ts { } return node; } - export function createJSDocUnionType(types?: Array): JSDocUnionType { - let node = createNode(SyntaxKind.JSDocUnionType); + export function createJSDocUnionType(types?: Array, location?: TextRange): JSDocUnionType { + let node = createNode(SyntaxKind.JSDocUnionType, location); node.types = types && createNodeArray(types) return node; } @@ -1837,8 +1848,8 @@ namespace ts { } return node; } - export function createJSDocTupleType(types?: Array): JSDocTupleType { - let node = createNode(SyntaxKind.JSDocTupleType); + export function createJSDocTupleType(types?: Array, location?: TextRange): JSDocTupleType { + let node = createNode(SyntaxKind.JSDocTupleType, location); node.types = types && createNodeArray(types) return node; } @@ -1849,8 +1860,8 @@ namespace ts { } return node; } - export function createJSDocNullableType(type?: JSDocType): JSDocNullableType { - let node = createNode(SyntaxKind.JSDocNullableType); + export function createJSDocNullableType(type?: JSDocType, location?: TextRange): JSDocNullableType { + let node = createNode(SyntaxKind.JSDocNullableType, location); node.type = type; return node; } @@ -1861,8 +1872,8 @@ namespace ts { } return node; } - export function createJSDocNonNullableType(type?: JSDocType): JSDocNonNullableType { - let node = createNode(SyntaxKind.JSDocNonNullableType); + export function createJSDocNonNullableType(type?: JSDocType, location?: TextRange): JSDocNonNullableType { + let node = createNode(SyntaxKind.JSDocNonNullableType, location); node.type = type; return node; } @@ -1873,8 +1884,8 @@ namespace ts { } return node; } - export function createJSDocRecordType(members?: Array): JSDocRecordType { - let node = createNode(SyntaxKind.JSDocRecordType); + export function createJSDocRecordType(members?: Array, location?: TextRange): JSDocRecordType { + let node = createNode(SyntaxKind.JSDocRecordType, location); node.members = members && createNodeArray(members) return node; } @@ -1885,8 +1896,8 @@ namespace ts { } return node; } - export function createJSDocRecordMember(name?: Identifier | LiteralExpression, type?: JSDocType): JSDocRecordMember { - let node = createNode(SyntaxKind.JSDocRecordMember); + export function createJSDocRecordMember(name?: Identifier | LiteralExpression, type?: JSDocType, location?: TextRange): JSDocRecordMember { + let node = createNode(SyntaxKind.JSDocRecordMember, location); if (arguments.length) { node.name = name; node.type = type; @@ -1900,8 +1911,8 @@ namespace ts { } return node; } - export function createJSDocTypeReference(name?: EntityName, typeArguments?: Array): JSDocTypeReference { - let node = createNode(SyntaxKind.JSDocTypeReference); + export function createJSDocTypeReference(name?: EntityName, typeArguments?: Array, location?: TextRange): JSDocTypeReference { + let node = createNode(SyntaxKind.JSDocTypeReference, location); if (arguments.length) { node.name = name; node.typeArguments = typeArguments && createNodeArray(typeArguments) @@ -1915,8 +1926,8 @@ namespace ts { } return node; } - export function createJSDocOptionalType(type?: JSDocType): JSDocOptionalType { - let node = createNode(SyntaxKind.JSDocOptionalType); + export function createJSDocOptionalType(type?: JSDocType, location?: TextRange): JSDocOptionalType { + let node = createNode(SyntaxKind.JSDocOptionalType, location); node.type = type; return node; } @@ -1927,8 +1938,9 @@ namespace ts { } return node; } - export function createJSDocFunctionType(parameters?: Array, type?: JSDocType): JSDocFunctionType { - let node = createNode(SyntaxKind.JSDocFunctionType); + export function createJSDocFunctionType(parameters?: Array, type?: JSDocType, + location?: TextRange): JSDocFunctionType { + let node = createNode(SyntaxKind.JSDocFunctionType, location); if (arguments.length) { node.parameters = parameters && createNodeArray(parameters) node.type = type; @@ -1943,8 +1955,8 @@ namespace ts { } return node; } - export function createJSDocVariadicType(type?: JSDocType): JSDocVariadicType { - let node = createNode(SyntaxKind.JSDocVariadicType); + export function createJSDocVariadicType(type?: JSDocType, location?: TextRange): JSDocVariadicType { + let node = createNode(SyntaxKind.JSDocVariadicType, location); node.type = type; return node; } @@ -1955,8 +1967,8 @@ namespace ts { } return node; } - export function createJSDocConstructorType(type?: JSDocType): JSDocConstructorType { - let node = createNode(SyntaxKind.JSDocConstructorType); + export function createJSDocConstructorType(type?: JSDocType, location?: TextRange): JSDocConstructorType { + let node = createNode(SyntaxKind.JSDocConstructorType, location); node.type = type; return node; } @@ -1967,8 +1979,8 @@ namespace ts { } return node; } - export function createJSDocThisType(type?: JSDocType): JSDocThisType { - let node = createNode(SyntaxKind.JSDocThisType); + export function createJSDocThisType(type?: JSDocType, location?: TextRange): JSDocThisType { + let node = createNode(SyntaxKind.JSDocThisType, location); node.type = type; return node; } @@ -1979,8 +1991,8 @@ namespace ts { } return node; } - export function createJSDocComment(tags?: Array): JSDocComment { - let node = createNode(SyntaxKind.JSDocComment); + export function createJSDocComment(tags?: Array, location?: TextRange): JSDocComment { + let node = createNode(SyntaxKind.JSDocComment, location); node.tags = tags && createNodeArray(tags) return node; } @@ -1991,8 +2003,8 @@ namespace ts { } return node; } - export function createJSDocTag(atToken?: Node, tagName?: Identifier): JSDocTag { - let node = createNode(SyntaxKind.JSDocTag); + export function createJSDocTag(atToken?: Node, tagName?: Identifier, location?: TextRange): JSDocTag { + let node = createNode(SyntaxKind.JSDocTag, location); if (arguments.length) { node.atToken = atToken; node.tagName = tagName; @@ -2007,8 +2019,8 @@ namespace ts { return node; } export function createJSDocParameterTag(preParameterName?: Identifier, typeExpression?: JSDocTypeExpression, postParameterName?: Identifier, - atToken?: Node, tagName?: Identifier): JSDocParameterTag { - let node = createNode(SyntaxKind.JSDocParameterTag); + atToken?: Node, tagName?: Identifier, location?: TextRange): JSDocParameterTag { + let node = createNode(SyntaxKind.JSDocParameterTag, location); if (arguments.length) { node.preParameterName = preParameterName; node.typeExpression = typeExpression; @@ -2027,8 +2039,9 @@ namespace ts { } return node; } - export function createJSDocReturnTag(typeExpression?: JSDocTypeExpression, atToken?: Node, tagName?: Identifier): JSDocReturnTag { - let node = createNode(SyntaxKind.JSDocReturnTag); + export function createJSDocReturnTag(typeExpression?: JSDocTypeExpression, atToken?: Node, tagName?: Identifier, + location?: TextRange): JSDocReturnTag { + let node = createNode(SyntaxKind.JSDocReturnTag, location); if (arguments.length) { node.typeExpression = typeExpression; node.atToken = atToken; @@ -2043,8 +2056,9 @@ namespace ts { } return node; } - export function createJSDocTypeTag(typeExpression?: JSDocTypeExpression, atToken?: Node, tagName?: Identifier): JSDocTypeTag { - let node = createNode(SyntaxKind.JSDocTypeTag); + export function createJSDocTypeTag(typeExpression?: JSDocTypeExpression, atToken?: Node, tagName?: Identifier, + location?: TextRange): JSDocTypeTag { + let node = createNode(SyntaxKind.JSDocTypeTag, location); if (arguments.length) { node.typeExpression = typeExpression; node.atToken = atToken; @@ -2059,9 +2073,9 @@ namespace ts { } return node; } - export function createJSDocTemplateTag(typeParameters?: Array, atToken?: Node, tagName?: Identifier - ): JSDocTemplateTag { - let node = createNode(SyntaxKind.JSDocTemplateTag); + export function createJSDocTemplateTag(typeParameters?: Array, atToken?: Node, tagName?: Identifier, + location?: TextRange): JSDocTemplateTag { + let node = createNode(SyntaxKind.JSDocTemplateTag, location); if (arguments.length) { node.typeParameters = typeParameters && createNodeArray(typeParameters) node.atToken = atToken; diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 59043d08366..0abdefebe9b 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -49,21 +49,21 @@ namespace ts { return newNode; } - export function createNode(kind: SyntaxKind): T { - return new (getNodeConstructor(kind))(); + export function createNode(kind: SyntaxKind, location?: TextRange): T { + return setTextRange(new (getNodeConstructor(kind))(), location); } - export function createNodeArray(elements?: TNode[]) { + export function createNodeArray(elements?: TNode[], location?: TextRange) { let nodes = >(elements || []); if (nodes.pos === undefined) { nodes.pos = -1; nodes.end = -1; } - return nodes; + return setTextRange(nodes, location); } - export function createModifiersArray(elements?: Node[]) { + export function createModifiersArray(elements?: Node[], location?: TextRange) { let modifiers = (elements || []); if (modifiers.flags === undefined) { let flags = 0; @@ -74,7 +74,7 @@ namespace ts { modifiers.flags = flags; } - return modifiers; + return setTextRange(modifiers, location); } export function createSourceFile(): SourceFile {