From e4b543981c2b5874cba970c5c61c5ccfd04fe30d Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Sat, 29 Nov 2014 15:58:55 -0800 Subject: [PATCH] Updating syntax kind names. --- src/compiler/binder.ts | 4 +- src/compiler/checker.ts | 114 ++++++++++----------- src/compiler/emitter.ts | 46 ++++----- src/compiler/parser.ts | 70 ++++++------- src/compiler/types.ts | 32 +++--- src/harness/typeWriter.ts | 12 +-- src/services/breakpoints.ts | 4 +- src/services/formatting/rules.ts | 4 +- src/services/outliningElementsCollector.ts | 4 +- src/services/services.ts | 30 +++--- src/services/smartIndenter.ts | 20 ++-- 11 files changed, 171 insertions(+), 169 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 5098b16e4bb..1502dbc8ead 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -279,7 +279,7 @@ module ts { break; } case SyntaxKind.TypeLiteral: - case SyntaxKind.ObjectLiteral: + case SyntaxKind.ObjectLiteralExpression: case SyntaxKind.InterfaceDeclaration: declareSymbol(container.symbol.members, container.symbol, node, symbolKind, symbolExcludes); break; @@ -436,7 +436,7 @@ module ts { case SyntaxKind.TypeLiteral: bindAnonymousDeclaration(node, SymbolFlags.TypeLiteral, "__type", /*isBlockScopeContainer*/ false); break; - case SyntaxKind.ObjectLiteral: + case SyntaxKind.ObjectLiteralExpression: bindAnonymousDeclaration(node, SymbolFlags.ObjectLiteral, "__object", /*isBlockScopeContainer*/ false); break; case SyntaxKind.FunctionExpression: diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index c020aa84b2e..0d1ad489c72 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3223,11 +3223,11 @@ module ts { case SyntaxKind.FunctionExpression: case SyntaxKind.ArrowFunction: return !(node).typeParameters && !forEach((node).parameters, p => p.type); - case SyntaxKind.ObjectLiteral: - return forEach((node).properties, p => + case SyntaxKind.ObjectLiteralExpression: + return forEach((node).properties, p => p.kind === SyntaxKind.PropertyAssignment && isContextSensitiveExpression((p).initializer)); - case SyntaxKind.ArrayLiteral: - return forEach((node).elements, e => isContextSensitiveExpression(e)); + case SyntaxKind.ArrayLiteralExpression: + return forEach((node).elements, e => isContextSensitiveExpression(e)); case SyntaxKind.ConditionalExpression: return isContextSensitiveExpression((node).whenTrue) || isContextSensitiveExpression((node).whenFalse); @@ -4302,8 +4302,8 @@ module ts { function isAssignedInBinaryExpression(node: BinaryExpression) { if (node.operator >= SyntaxKind.FirstAssignment && node.operator <= SyntaxKind.LastAssignment) { var n = node.left; - while (n.kind === SyntaxKind.ParenExpression) { - n = (n).expression; + while (n.kind === SyntaxKind.ParenthesizedExpression) { + n = (n).expression; } if (n.kind === SyntaxKind.Identifier && getResolvedSymbol(n) === symbol) { return true; @@ -4325,19 +4325,19 @@ module ts { return isAssignedInBinaryExpression(node); case SyntaxKind.VariableDeclaration: return isAssignedInVariableDeclaration(node); - case SyntaxKind.ArrayLiteral: - case SyntaxKind.ObjectLiteral: - case SyntaxKind.PropertyAccess: + case SyntaxKind.ArrayLiteralExpression: + case SyntaxKind.ObjectLiteralExpression: + case SyntaxKind.PropertyAccessExpression: case SyntaxKind.ElementAccessExpression: case SyntaxKind.CallExpression: case SyntaxKind.NewExpression: - case SyntaxKind.TypeAssertion: - case SyntaxKind.ParenExpression: + case SyntaxKind.TypeAssertionExpression: + case SyntaxKind.ParenthesizedExpression: case SyntaxKind.PrefixUnaryExpression: case SyntaxKind.DeleteExpression: case SyntaxKind.TypeOfExpression: case SyntaxKind.VoidExpression: - case SyntaxKind.PostfixOperator: + case SyntaxKind.PostfixUnaryExpression: case SyntaxKind.ConditionalExpression: case SyntaxKind.Block: case SyntaxKind.VariableStatement: @@ -4496,8 +4496,8 @@ module ts { // Narrow the given type based on the given expression having the assumed boolean value function narrowType(type: Type, expr: Expression, assumeTrue: boolean): Type { switch (expr.kind) { - case SyntaxKind.ParenExpression: - return narrowType(type, (expr).expression, assumeTrue); + case SyntaxKind.ParenthesizedExpression: + return narrowType(type, (expr).expression, assumeTrue); case SyntaxKind.BinaryExpression: var operator = (expr).operator; if (operator === SyntaxKind.EqualsEqualsEqualsToken || operator === SyntaxKind.ExclamationEqualsEqualsToken) { @@ -4864,7 +4864,7 @@ module ts { // exists. Otherwise, it is the type of the string index signature in T, if one exists. function getContextualTypeForPropertyExpression(node: Expression): Type { var declaration = node.parent; - var objectLiteral = declaration.parent; + var objectLiteral = declaration.parent; var type = getContextualType(objectLiteral); // TODO(jfreeman): Handle this case for computed names and symbols var name = (declaration.name).text; @@ -4880,7 +4880,7 @@ module ts { // the type of the property with the numeric name N in T, if one exists. Otherwise, it is the type of the numeric // index signature in T, if one exists. function getContextualTypeForElementExpression(node: Expression): Type { - var arrayLiteral = node.parent; + var arrayLiteral = node.parent; var type = getContextualType(arrayLiteral); if (type) { var index = indexOf(arrayLiteral.elements, node); @@ -4917,13 +4917,13 @@ module ts { case SyntaxKind.CallExpression: case SyntaxKind.NewExpression: return getContextualTypeForArgument(node); - case SyntaxKind.TypeAssertion: + case SyntaxKind.TypeAssertionExpression: return getTypeFromTypeNode((parent).type); case SyntaxKind.BinaryExpression: return getContextualTypeForBinaryOperand(node); case SyntaxKind.PropertyAssignment: return getContextualTypeForPropertyExpression(node); - case SyntaxKind.ArrayLiteral: + case SyntaxKind.ArrayLiteralExpression: return getContextualTypeForElementExpression(node); case SyntaxKind.ConditionalExpression: return getContextualTypeForConditionalOperand(node); @@ -5000,7 +5000,7 @@ module ts { return mapper && mapper !== identityMapper; } - function checkArrayLiteral(node: ArrayLiteral, contextualMapper?: TypeMapper): Type { + function checkArrayLiteral(node: ArrayLiteralExpression, contextualMapper?: TypeMapper): Type { var elements = node.elements; if (!elements.length) { return createArrayType(undefinedType); @@ -5038,7 +5038,7 @@ module ts { return (+name).toString() === name; } - function checkObjectLiteral(node: ObjectLiteral, contextualMapper?: TypeMapper): Type { + function checkObjectLiteral(node: ObjectLiteralExpression, contextualMapper?: TypeMapper): Type { var members = node.symbol.members; var properties: SymbolTable = {}; var contextualType = getContextualType(node); @@ -5115,7 +5115,7 @@ module ts { return s.valueDeclaration ? s.valueDeclaration.flags : s.flags & SymbolFlags.Prototype ? NodeFlags.Public | NodeFlags.Static : 0; } - function checkClassPropertyAccess(node: PropertyAccess, type: Type, prop: Symbol) { + function checkClassPropertyAccess(node: PropertyAccessExpression, type: Type, prop: Symbol) { var flags = getDeclarationFlagsFromSymbol(prop); // Public properties are always accessible if (!(flags & (NodeFlags.Private | NodeFlags.Protected))) { @@ -5153,7 +5153,7 @@ module ts { } } - function checkPropertyAccess(node: PropertyAccess) { + function checkPropertyAccess(node: PropertyAccessExpression) { var type = checkExpression(node.left); if (type === unknownType) return type; if (type !== anyType) { @@ -5190,7 +5190,7 @@ module ts { return anyType; } - function isValidPropertyAccess(node: PropertyAccess, propertyName: string): boolean { + function isValidPropertyAccess(node: PropertyAccessExpression, propertyName: string): boolean { var type = checkExpression(node.left); if (type !== unknownType && type !== anyType) { var prop = getPropertyOfType(getWidenedType(type), propertyName); @@ -6165,7 +6165,7 @@ module ts { // An identifier expression that references a variable or parameter is classified as a reference. // An identifier expression that references any other kind of entity is classified as a value(and therefore cannot be the target of an assignment). return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & SymbolFlags.Variable) !== 0; - case SyntaxKind.PropertyAccess: + case SyntaxKind.PropertyAccessExpression: var symbol = findSymbol(n); // TypeScript 1.0 spec (April 2014): 4.10 // A property access expression is always classified as a reference. @@ -6174,8 +6174,8 @@ module ts { case SyntaxKind.ElementAccessExpression: // old compiler doesn't check indexed assess return true; - case SyntaxKind.ParenExpression: - return isReferenceOrErrorExpression((n).expression); + case SyntaxKind.ParenthesizedExpression: + return isReferenceOrErrorExpression((n).expression); default: return false; } @@ -6184,7 +6184,7 @@ module ts { function isConstVariableReference(n: Node): boolean { switch (n.kind) { case SyntaxKind.Identifier: - case SyntaxKind.PropertyAccess: + case SyntaxKind.PropertyAccessExpression: var symbol = findSymbol(n); return symbol && (symbol.flags & SymbolFlags.Variable) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & NodeFlags.Const) !== 0; case SyntaxKind.ElementAccessExpression: @@ -6196,8 +6196,8 @@ module ts { return prop && (prop.flags & SymbolFlags.Variable) !== 0 && (getDeclarationFlagsFromSymbol(prop) & NodeFlags.Const) !== 0; } return false; - case SyntaxKind.ParenExpression: - return isConstVariableReference((n).expression); + case SyntaxKind.ParenthesizedExpression: + return isConstVariableReference((n).expression); default: return false; } @@ -6524,7 +6524,7 @@ module ts { // - 'object' in indexed access // - target in rhs of import statement var ok = - (node.parent.kind === SyntaxKind.PropertyAccess && (node.parent).left === node) || + (node.parent.kind === SyntaxKind.PropertyAccessExpression && (node.parent).left === node) || (node.parent.kind === SyntaxKind.ElementAccessExpression && (node.parent).expression === node) || ((node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.QualifiedName) && isInRightSideOfImportOrExportAssignment(node)); @@ -6559,12 +6559,12 @@ module ts { return globalRegExpType; case SyntaxKind.QualifiedName: return checkPropertyAccess(node); - case SyntaxKind.ArrayLiteral: - return checkArrayLiteral(node, contextualMapper); - case SyntaxKind.ObjectLiteral: - return checkObjectLiteral(node, contextualMapper); - case SyntaxKind.PropertyAccess: - return checkPropertyAccess(node); + case SyntaxKind.ArrayLiteralExpression: + return checkArrayLiteral(node, contextualMapper); + case SyntaxKind.ObjectLiteralExpression: + return checkObjectLiteral(node, contextualMapper); + case SyntaxKind.PropertyAccessExpression: + return checkPropertyAccess(node); case SyntaxKind.ElementAccessExpression: return checkIndexedAccess(node); case SyntaxKind.CallExpression: @@ -6572,10 +6572,10 @@ module ts { return checkCallExpression(node); case SyntaxKind.TaggedTemplateExpression: return checkTaggedTemplateExpression(node); - case SyntaxKind.TypeAssertion: + case SyntaxKind.TypeAssertionExpression: return checkTypeAssertion(node); - case SyntaxKind.ParenExpression: - return checkExpression((node).expression); + case SyntaxKind.ParenthesizedExpression: + return checkExpression((node).expression); case SyntaxKind.FunctionExpression: case SyntaxKind.ArrowFunction: return checkFunctionExpression(node, contextualMapper); @@ -6587,7 +6587,7 @@ module ts { return checkVoidExpression(node); case SyntaxKind.PrefixUnaryExpression: return checkPrefixExpression(node); - case SyntaxKind.PostfixOperator: + case SyntaxKind.PostfixUnaryExpression: return checkPostfixExpression(node); case SyntaxKind.BinaryExpression: return checkBinaryExpression(node, contextualMapper); @@ -6774,7 +6774,7 @@ module ts { case SyntaxKind.FunctionExpression: case SyntaxKind.FunctionDeclaration: case SyntaxKind.ArrowFunction: - case SyntaxKind.ObjectLiteral: return false; + case SyntaxKind.ObjectLiteralExpression: return false; default: return forEachChild(n, containsSuperCall); } } @@ -8136,11 +8136,11 @@ module ts { return undefined; case SyntaxKind.NumericLiteral: return +(e).text; - case SyntaxKind.ParenExpression: - return enumIsConst ? evalConstant((e).expression) : undefined; + case SyntaxKind.ParenthesizedExpression: + return enumIsConst ? evalConstant((e).expression) : undefined; case SyntaxKind.Identifier: case SyntaxKind.ElementAccessExpression: - case SyntaxKind.PropertyAccess: + case SyntaxKind.PropertyAccessExpression: if (!enumIsConst) { return undefined; } @@ -8165,8 +8165,8 @@ module ts { propertyName = ((e).argumentExpression).text; } else { - var enumType = getTypeOfNode((e).left); - propertyName = (e).right.text; + var enumType = getTypeOfNode((e).left); + propertyName = (e).right.text; } if (enumType !== currentType) { return undefined; @@ -8487,21 +8487,21 @@ module ts { break; case SyntaxKind.Parameter: case SyntaxKind.Property: - case SyntaxKind.ArrayLiteral: - case SyntaxKind.ObjectLiteral: + case SyntaxKind.ArrayLiteralExpression: + case SyntaxKind.ObjectLiteralExpression: case SyntaxKind.PropertyAssignment: - case SyntaxKind.PropertyAccess: + case SyntaxKind.PropertyAccessExpression: case SyntaxKind.ElementAccessExpression: case SyntaxKind.CallExpression: case SyntaxKind.NewExpression: case SyntaxKind.TaggedTemplateExpression: - case SyntaxKind.TypeAssertion: - case SyntaxKind.ParenExpression: + case SyntaxKind.TypeAssertionExpression: + case SyntaxKind.ParenthesizedExpression: case SyntaxKind.TypeOfExpression: case SyntaxKind.VoidExpression: case SyntaxKind.DeleteExpression: case SyntaxKind.PrefixUnaryExpression: - case SyntaxKind.PostfixOperator: + case SyntaxKind.PostfixUnaryExpression: case SyntaxKind.BinaryExpression: case SyntaxKind.ConditionalExpression: case SyntaxKind.Block: @@ -8776,7 +8776,7 @@ module ts { case SyntaxKind.ConstructSignature: case SyntaxKind.IndexSignature: return node === (parent).type; - case SyntaxKind.TypeAssertion: + case SyntaxKind.TypeAssertionExpression: return node === (parent).type; case SyntaxKind.CallExpression: case SyntaxKind.NewExpression: @@ -8806,7 +8806,7 @@ module ts { } function isRightSideOfQualifiedNameOrPropertyAccess(node: Node) { - return (node.parent.kind === SyntaxKind.QualifiedName || node.parent.kind === SyntaxKind.PropertyAccess) && + return (node.parent.kind === SyntaxKind.QualifiedName || node.parent.kind === SyntaxKind.PropertyAccessExpression) && (node.parent).right === node; } @@ -8836,7 +8836,7 @@ module ts { var meaning: SymbolFlags = SymbolFlags.Value | SymbolFlags.Import; return resolveEntityName(entityName, entityName, meaning); } - else if (entityName.kind === SyntaxKind.QualifiedName || entityName.kind === SyntaxKind.PropertyAccess) { + else if (entityName.kind === SyntaxKind.QualifiedName || entityName.kind === SyntaxKind.PropertyAccessExpression) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccess(entityName); @@ -8879,7 +8879,7 @@ module ts { switch (node.kind) { case SyntaxKind.Identifier: - case SyntaxKind.PropertyAccess: + case SyntaxKind.PropertyAccessExpression: case SyntaxKind.QualifiedName: return getSymbolOfEntityName(node); @@ -9160,7 +9160,7 @@ module ts { return getNodeLinks(node).enumMemberValue; } - function getConstantValue(node: PropertyAccess | ElementAccessExpression): number { + function getConstantValue(node: PropertyAccessExpression | ElementAccessExpression): number { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol && (symbol.flags & SymbolFlags.EnumMember)) { var declaration = symbol.valueDeclaration; diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index de3c5ca19c9..a68b12bebd7 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -1996,7 +1996,7 @@ module ts { // ("abc" + 1) << (2 + "") // rather than // "abc" + (1 << 2) + "" - var needsParens = templateSpan.expression.kind !== SyntaxKind.ParenExpression + var needsParens = templateSpan.expression.kind !== SyntaxKind.ParenthesizedExpression && comparePrecedenceToBinaryPlus(templateSpan.expression) !== Comparison.GreaterThan; write(" + "); @@ -2028,7 +2028,7 @@ module ts { case SyntaxKind.CallExpression: case SyntaxKind.NewExpression: return (parent).expression === template; - case SyntaxKind.ParenExpression: + case SyntaxKind.ParenthesizedExpression: return false; case SyntaxKind.TaggedTemplateExpression: Debug.fail("Path should be unreachable; tagged templates not supported pre-ES6."); @@ -2170,7 +2170,7 @@ module ts { } } - function emitArrayLiteral(node: ArrayLiteral) { + function emitArrayLiteral(node: ArrayLiteralExpression) { if (node.flags & NodeFlags.MultiLine) { write("["); increaseIndent(); @@ -2186,7 +2186,7 @@ module ts { } } - function emitObjectLiteral(node: ObjectLiteral) { + function emitObjectLiteral(node: ObjectLiteralExpression) { if (!node.properties.length) { write("{}"); } @@ -2249,17 +2249,17 @@ module ts { } } - function tryEmitConstantValue(node: PropertyAccess | ElementAccessExpression): boolean { + function tryEmitConstantValue(node: PropertyAccessExpression | ElementAccessExpression): boolean { var constantValue = resolver.getConstantValue(node); if (constantValue !== undefined) { - var propertyName = node.kind === SyntaxKind.PropertyAccess ? declarationNameToString((node).right) : getTextOfNode((node).argumentExpression); + var propertyName = node.kind === SyntaxKind.PropertyAccessExpression ? declarationNameToString((node).right) : getTextOfNode((node).argumentExpression); write(constantValue.toString() + " /* " + propertyName + " */"); return true; } return false; } - function emitPropertyAccess(node: PropertyAccess) { + function emitPropertyAccess(node: PropertyAccessExpression) { if (tryEmitConstantValue(node)) { return; } @@ -2286,7 +2286,7 @@ module ts { } else { emit(node.expression); - superCall = node.expression.kind === SyntaxKind.PropertyAccess && (node.expression).left.kind === SyntaxKind.SuperKeyword; + superCall = node.expression.kind === SyntaxKind.PropertyAccessExpression && (node.expression).left.kind === SyntaxKind.SuperKeyword; } if (superCall) { write(".call("); @@ -2321,13 +2321,13 @@ module ts { emit(node.template); } - function emitParenExpression(node: ParenExpression) { - if (node.expression.kind === SyntaxKind.TypeAssertion) { + function emitParenExpression(node: ParenthesizedExpression) { + if (node.expression.kind === SyntaxKind.TypeAssertionExpression) { var operand = (node.expression).expression; // Make sure we consider all nested cast expressions, e.g.: // (-A).x; - while (operand.kind == SyntaxKind.TypeAssertion) { + while (operand.kind == SyntaxKind.TypeAssertionExpression) { operand = (operand).expression; } @@ -2343,7 +2343,7 @@ module ts { operand.kind !== SyntaxKind.VoidExpression && operand.kind !== SyntaxKind.TypeOfExpression && operand.kind !== SyntaxKind.DeleteExpression && - operand.kind !== SyntaxKind.PostfixOperator && + operand.kind !== SyntaxKind.PostfixUnaryExpression && operand.kind !== SyntaxKind.NewExpression && !(operand.kind === SyntaxKind.CallExpression && node.parent.kind === SyntaxKind.NewExpression) && !(operand.kind === SyntaxKind.FunctionExpression && node.parent.kind === SyntaxKind.CallExpression)) { @@ -2403,7 +2403,7 @@ module ts { } } emit(node.operand); - if (node.kind === SyntaxKind.PostfixOperator) { + if (node.kind === SyntaxKind.PostfixUnaryExpression) { write(tokenToString(node.operator)); } } @@ -3495,18 +3495,18 @@ module ts { return emitTemplateSpan(node); case SyntaxKind.QualifiedName: return emitPropertyAccess(node); - case SyntaxKind.ArrayLiteral: - return emitArrayLiteral(node); - case SyntaxKind.ObjectLiteral: - return emitObjectLiteral(node); + case SyntaxKind.ArrayLiteralExpression: + return emitArrayLiteral(node); + case SyntaxKind.ObjectLiteralExpression: + return emitObjectLiteral(node); case SyntaxKind.PropertyAssignment: return emitPropertyAssignment(node); case SyntaxKind.ShorthandPropertyAssignment: return emitShortHandPropertyAssignment(node); case SyntaxKind.ComputedPropertyName: return emitComputedPropertyName(node); - case SyntaxKind.PropertyAccess: - return emitPropertyAccess(node); + case SyntaxKind.PropertyAccessExpression: + return emitPropertyAccess(node); case SyntaxKind.ElementAccessExpression: return emitIndexedAccess(node); case SyntaxKind.CallExpression: @@ -3515,10 +3515,10 @@ module ts { return emitNewExpression(node); case SyntaxKind.TaggedTemplateExpression: return emitTaggedTemplateExpression(node); - case SyntaxKind.TypeAssertion: + case SyntaxKind.TypeAssertionExpression: return emit((node).expression); - case SyntaxKind.ParenExpression: - return emitParenExpression(node); + case SyntaxKind.ParenthesizedExpression: + return emitParenExpression(node); case SyntaxKind.FunctionDeclaration: case SyntaxKind.FunctionExpression: case SyntaxKind.ArrowFunction: @@ -3530,7 +3530,7 @@ module ts { case SyntaxKind.VoidExpression: return emitVoidExpression(node); case SyntaxKind.PrefixUnaryExpression: - case SyntaxKind.PostfixOperator: + case SyntaxKind.PostfixUnaryExpression: return emitUnaryExpression(node); case SyntaxKind.BinaryExpression: return emitBinaryExpression(node); diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index a1636357fe5..654abac6d57 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -255,13 +255,13 @@ module ts { return children((node).types); case SyntaxKind.ParenthesizedType: return child((node).type); - case SyntaxKind.ArrayLiteral: - return children((node).elements); - case SyntaxKind.ObjectLiteral: - return children((node).properties); - case SyntaxKind.PropertyAccess: - return child((node).left) || - child((node).right); + case SyntaxKind.ArrayLiteralExpression: + return children((node).elements); + case SyntaxKind.ObjectLiteralExpression: + return children((node).properties); + case SyntaxKind.PropertyAccessExpression: + return child((node).left) || + child((node).right); case SyntaxKind.ElementAccessExpression: return child((node).expression) || child((node).argumentExpression); @@ -273,11 +273,11 @@ module ts { case SyntaxKind.TaggedTemplateExpression: return child((node).tag) || child((node).template); - case SyntaxKind.TypeAssertion: + case SyntaxKind.TypeAssertionExpression: return child((node).type) || child((node).expression); - case SyntaxKind.ParenExpression: - return child((node).expression); + case SyntaxKind.ParenthesizedExpression: + return child((node).expression); case SyntaxKind.DeleteExpression: return child((node).expression); case SyntaxKind.TypeOfExpression: @@ -285,7 +285,7 @@ module ts { case SyntaxKind.VoidExpression: return child((node).expression); case SyntaxKind.PrefixUnaryExpression: - case SyntaxKind.PostfixOperator: + case SyntaxKind.PostfixUnaryExpression: return child((node).operand); case SyntaxKind.BinaryExpression: return child((node).left) || @@ -513,22 +513,22 @@ module ts { case SyntaxKind.TrueKeyword: case SyntaxKind.FalseKeyword: case SyntaxKind.RegularExpressionLiteral: - case SyntaxKind.ArrayLiteral: - case SyntaxKind.ObjectLiteral: - case SyntaxKind.PropertyAccess: + case SyntaxKind.ArrayLiteralExpression: + case SyntaxKind.ObjectLiteralExpression: + case SyntaxKind.PropertyAccessExpression: case SyntaxKind.ElementAccessExpression: case SyntaxKind.CallExpression: case SyntaxKind.NewExpression: case SyntaxKind.TaggedTemplateExpression: - case SyntaxKind.TypeAssertion: - case SyntaxKind.ParenExpression: + case SyntaxKind.TypeAssertionExpression: + case SyntaxKind.ParenthesizedExpression: case SyntaxKind.FunctionExpression: case SyntaxKind.ArrowFunction: case SyntaxKind.VoidExpression: case SyntaxKind.DeleteExpression: case SyntaxKind.TypeOfExpression: case SyntaxKind.PrefixUnaryExpression: - case SyntaxKind.PostfixOperator: + case SyntaxKind.PostfixUnaryExpression: case SyntaxKind.BinaryExpression: case SyntaxKind.ConditionalExpression: case SyntaxKind.TemplateExpression: @@ -571,7 +571,7 @@ module ts { case SyntaxKind.ForInStatement: return (parent).variable === node || (parent).expression === node; - case SyntaxKind.TypeAssertion: + case SyntaxKind.TypeAssertionExpression: return node === (parent).expression; case SyntaxKind.TemplateSpan: return node === (parent).expression; @@ -2676,7 +2676,7 @@ module ts { if ((token === SyntaxKind.PlusPlusToken || token === SyntaxKind.MinusMinusToken) && !scanner.hasPrecedingLineBreak()) { var operator = token; nextToken(); - return makeUnaryExpression(SyntaxKind.PostfixOperator, expression.pos, operator, expression); + return makeUnaryExpression(SyntaxKind.PostfixUnaryExpression, expression.pos, operator, expression); } return expression; @@ -2786,7 +2786,7 @@ module ts { // If we have seen "super" it must be followed by '(' or '.'. // If it wasn't then just try to parse out a '.' and report an error. - var node = createNode(SyntaxKind.PropertyAccess, expression.pos); + var node = createNode(SyntaxKind.PropertyAccessExpression, expression.pos); node.left = expression; parseExpected(SyntaxKind.DotToken, Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.right = parseIdentifierName(); @@ -2794,7 +2794,7 @@ module ts { } function parseTypeAssertion(): TypeAssertion { - var node = createNode(SyntaxKind.TypeAssertion); + var node = createNode(SyntaxKind.TypeAssertionExpression); parseExpected(SyntaxKind.LessThanToken); node.type = parseType(); parseExpected(SyntaxKind.GreaterThanToken); @@ -2813,7 +2813,7 @@ module ts { while (true) { var dotOrBracketStart = scanner.getTokenPos(); if (parseOptional(SyntaxKind.DotToken)) { - var propertyAccess = createNode(SyntaxKind.PropertyAccess, expression.pos); + var propertyAccess = createNode(SyntaxKind.PropertyAccessExpression, expression.pos); // Technically a keyword is valid here as all keywords are identifier names. // However, often we'll encounter this in error situations when the keyword // is actually starting another valid construct. @@ -2990,8 +2990,8 @@ module ts { return createMissingNode(); } - function parseParenExpression(): ParenExpression { - var node = createNode(SyntaxKind.ParenExpression); + function parseParenExpression(): ParenthesizedExpression { + var node = createNode(SyntaxKind.ParenthesizedExpression); parseExpected(SyntaxKind.OpenParenToken); node.expression = allowInAnd(parseExpression); parseExpected(SyntaxKind.CloseParenToken); @@ -3012,8 +3012,8 @@ module ts { return allowInAnd(parseAssignmentExpressionOrOmittedExpression); } - function parseArrayLiteral(): ArrayLiteral { - var node = createNode(SyntaxKind.ArrayLiteral); + function parseArrayLiteral(): ArrayLiteralExpression { + var node = createNode(SyntaxKind.ArrayLiteralExpression); parseExpected(SyntaxKind.OpenBracketToken); if (scanner.hasPrecedingLineBreak()) node.flags |= NodeFlags.MultiLine; node.elements = parseDelimitedList(ParsingContext.ArrayLiteralMembers, parseArrayLiteralElement); @@ -3077,8 +3077,8 @@ module ts { return parsePropertyAssignment(); } - function parseObjectLiteral(): ObjectLiteral { - var node = createNode(SyntaxKind.ObjectLiteral); + function parseObjectLiteral(): ObjectLiteralExpression { + var node = createNode(SyntaxKind.ObjectLiteralExpression); parseExpected(SyntaxKind.OpenBraceToken); if (scanner.hasPrecedingLineBreak()) { node.flags |= NodeFlags.MultiLine; @@ -4119,14 +4119,14 @@ module ts { function isLeftHandSideExpression(expr: Expression): boolean { if (expr) { switch (expr.kind) { - case SyntaxKind.PropertyAccess: + case SyntaxKind.PropertyAccessExpression: case SyntaxKind.ElementAccessExpression: case SyntaxKind.NewExpression: case SyntaxKind.CallExpression: case SyntaxKind.TaggedTemplateExpression: - case SyntaxKind.ArrayLiteral: - case SyntaxKind.ParenExpression: - case SyntaxKind.ObjectLiteral: + case SyntaxKind.ArrayLiteralExpression: + case SyntaxKind.ParenthesizedExpression: + case SyntaxKind.ObjectLiteralExpression: case SyntaxKind.FunctionExpression: case SyntaxKind.Identifier: case SyntaxKind.Missing: @@ -4242,10 +4242,10 @@ module ts { case SyntaxKind.LabeledStatement: return checkLabeledStatement(node); case SyntaxKind.Method: return checkMethod(node); case SyntaxKind.ModuleDeclaration: return checkModuleDeclaration(node); - case SyntaxKind.ObjectLiteral: return checkObjectLiteral(node); + case SyntaxKind.ObjectLiteralExpression: return checkObjectLiteral(node); case SyntaxKind.NumericLiteral: return checkNumericLiteral(node); case SyntaxKind.Parameter: return checkParameter(node); - case SyntaxKind.PostfixOperator: return checkPostfixOperator(node); + case SyntaxKind.PostfixUnaryExpression: return checkPostfixOperator(node); case SyntaxKind.PrefixUnaryExpression: return checkPrefixOperator(node); case SyntaxKind.Property: return checkProperty(node); case SyntaxKind.PropertyAssignment: return checkPropertyAssignment(node); @@ -4763,7 +4763,7 @@ module ts { } } - function checkObjectLiteral(node: ObjectLiteral): boolean { + function checkObjectLiteral(node: ObjectLiteralExpression): boolean { var seen: Map = {}; var Property = 1; var GetAccessor = 2; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 242f6243a71..dfc39b1612d 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -165,30 +165,29 @@ module ts { UnionType, ParenthesizedType, // Expression - ArrayLiteral, - ObjectLiteral, - PropertyAssignment, - ShorthandPropertyAssignment, - PropertyAccess, + ArrayLiteralExpression, + ObjectLiteralExpression, + PropertyAccessExpression, ElementAccessExpression, CallExpression, NewExpression, TaggedTemplateExpression, - TypeAssertion, - ParenExpression, + TypeAssertionExpression, + ParenthesizedExpression, FunctionExpression, ArrowFunction, DeleteExpression, TypeOfExpression, VoidExpression, PrefixUnaryExpression, - PostfixOperator, + PostfixUnaryExpression, BinaryExpression, ConditionalExpression, TemplateExpression, - TemplateSpan, YieldExpression, OmittedExpression, + // Misc + TemplateSpan, // Element Block, VariableStatement, @@ -224,6 +223,9 @@ module ts { ModuleBlock, ImportDeclaration, ExportAssignment, + // Property assignments + PropertyAssignment, + ShorthandPropertyAssignment, // Enum EnumMember, // Top-level nodes @@ -495,19 +497,19 @@ module ts { literal: LiteralExpression; } - export interface ParenExpression extends Expression { + export interface ParenthesizedExpression extends Expression { expression: Expression; } - export interface ArrayLiteral extends Expression { + export interface ArrayLiteralExpression extends Expression { elements: NodeArray; } - export interface ObjectLiteral extends Expression { + export interface ObjectLiteralExpression extends Expression { properties: NodeArray; } - export interface PropertyAccess extends Expression { + export interface PropertyAccessExpression extends Expression { left: Expression; right: Identifier; } @@ -799,7 +801,7 @@ module ts { isEmitBlocked(sourceFile?: SourceFile): boolean; // Returns the constant value of this enum member, or 'undefined' if the enum member has a computed value. getEnumMemberValue(node: EnumMember): number; - isValidPropertyAccess(node: PropertyAccess, propertyName: string): boolean; + isValidPropertyAccess(node: PropertyAccessExpression, propertyName: string): boolean; getAliasedSymbol(symbol: Symbol): Symbol; } @@ -890,7 +892,7 @@ module ts { isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags): SymbolAccessiblityResult; isEntityNameVisible(entityName: EntityName, enclosingDeclaration: Node): SymbolVisibilityResult; // Returns the constant value this property access resolves to, or 'undefined' for a non-constant - getConstantValue(node: PropertyAccess | ElementAccessExpression): number; + getConstantValue(node: PropertyAccessExpression | ElementAccessExpression): number; isEmitBlocked(sourceFile?: SourceFile): boolean; } diff --git a/src/harness/typeWriter.ts b/src/harness/typeWriter.ts index 5d5ecaa661f..83aaaaf920a 100644 --- a/src/harness/typeWriter.ts +++ b/src/harness/typeWriter.ts @@ -29,21 +29,21 @@ class TypeWriterWalker { // old typeWriter baselines, suppress tokens case ts.SyntaxKind.ThisKeyword: case ts.SyntaxKind.SuperKeyword: - case ts.SyntaxKind.ArrayLiteral: - case ts.SyntaxKind.ObjectLiteral: - case ts.SyntaxKind.PropertyAccess: + case ts.SyntaxKind.ArrayLiteralExpression: + case ts.SyntaxKind.ObjectLiteralExpression: + case ts.SyntaxKind.PropertyAccessExpression: case ts.SyntaxKind.ElementAccessExpression: case ts.SyntaxKind.CallExpression: case ts.SyntaxKind.NewExpression: - case ts.SyntaxKind.TypeAssertion: - case ts.SyntaxKind.ParenExpression: + case ts.SyntaxKind.TypeAssertionExpression: + case ts.SyntaxKind.ParenthesizedExpression: case ts.SyntaxKind.FunctionExpression: case ts.SyntaxKind.ArrowFunction: case ts.SyntaxKind.TypeOfExpression: case ts.SyntaxKind.VoidExpression: case ts.SyntaxKind.DeleteExpression: case ts.SyntaxKind.PrefixUnaryExpression: - case ts.SyntaxKind.PostfixOperator: + case ts.SyntaxKind.PostfixUnaryExpression: case ts.SyntaxKind.BinaryExpression: case ts.SyntaxKind.ConditionalExpression: this.log(node, this.getTypeOfNode(node)); diff --git a/src/services/breakpoints.ts b/src/services/breakpoints.ts index fe7c3af5597..d4aa5e40f39 100644 --- a/src/services/breakpoints.ts +++ b/src/services/breakpoints.ts @@ -242,7 +242,7 @@ module ts.BreakpointResolver { } // Breakpoint in type assertion goes to its operand - if (node.parent.kind === SyntaxKind.TypeAssertion && (node.parent).type === node) { + if (node.parent.kind === SyntaxKind.TypeAssertionExpression && (node.parent).type === node) { return spanInNode((node.parent).expression); } @@ -483,7 +483,7 @@ module ts.BreakpointResolver { } function spanInGreaterThanOrLessThanToken(node: Node): TextSpan { - if (node.parent.kind === SyntaxKind.TypeAssertion) { + if (node.parent.kind === SyntaxKind.TypeAssertionExpression) { return spanInNode((node.parent).expression); } diff --git a/src/services/formatting/rules.ts b/src/services/formatting/rules.ts index 9985fe61b1a..7de7baee6ca 100644 --- a/src/services/formatting/rules.ts +++ b/src/services/formatting/rules.ts @@ -523,7 +523,7 @@ module ts.formatting { switch (node.kind) { case SyntaxKind.Block: case SyntaxKind.SwitchStatement: - case SyntaxKind.ObjectLiteral: + case SyntaxKind.ObjectLiteralExpression: case SyntaxKind.TryBlock: case SyntaxKind.CatchBlock: case SyntaxKind.FinallyBlock: @@ -613,7 +613,7 @@ module ts.formatting { } static IsObjectContext(context: FormattingContext): boolean { - return context.contextNode.kind === SyntaxKind.ObjectLiteral; + return context.contextNode.kind === SyntaxKind.ObjectLiteralExpression; } static IsFunctionCallContext(context: FormattingContext): boolean { diff --git a/src/services/outliningElementsCollector.ts b/src/services/outliningElementsCollector.ts index 27f75b8d20e..7f071e5c224 100644 --- a/src/services/outliningElementsCollector.ts +++ b/src/services/outliningElementsCollector.ts @@ -109,13 +109,13 @@ module ts { case SyntaxKind.ClassDeclaration: case SyntaxKind.InterfaceDeclaration: case SyntaxKind.EnumDeclaration: - case SyntaxKind.ObjectLiteral: + case SyntaxKind.ObjectLiteralExpression: case SyntaxKind.SwitchStatement: var openBrace = findChildOfKind(n, SyntaxKind.OpenBraceToken, sourceFile); var closeBrace = findChildOfKind(n, SyntaxKind.CloseBraceToken, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; - case SyntaxKind.ArrayLiteral: + case SyntaxKind.ArrayLiteralExpression: var openBracket = findChildOfKind(n, SyntaxKind.OpenBracketToken, sourceFile); var closeBracket = findChildOfKind(n, SyntaxKind.CloseBracketToken, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); diff --git a/src/services/services.ts b/src/services/services.ts index 4e7da91bbf5..04acf4837b3 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1927,7 +1927,7 @@ module ts { } function isRightSideOfPropertyAccess(node: Node) { - return node && node.parent && node.parent.kind === SyntaxKind.PropertyAccess && (node.parent).right === node; + return node && node.parent && node.parent.kind === SyntaxKind.PropertyAccessExpression && (node.parent).right === node; } function isCallExpressionTarget(node: Node): boolean { @@ -2374,8 +2374,8 @@ module ts { var node: Node; var isRightOfDot: boolean; if (previousToken && previousToken.kind === SyntaxKind.DotToken && - (previousToken.parent.kind === SyntaxKind.PropertyAccess || previousToken.parent.kind === SyntaxKind.QualifiedName)) { - node = (previousToken.parent).left; + (previousToken.parent.kind === SyntaxKind.PropertyAccessExpression || previousToken.parent.kind === SyntaxKind.QualifiedName)) { + node = (previousToken.parent).left; isRightOfDot = true; } else { @@ -2401,7 +2401,7 @@ module ts { var symbols: Symbol[] = []; isMemberCompletion = true; - if (node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.QualifiedName || node.kind === SyntaxKind.PropertyAccess) { + if (node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.QualifiedName || node.kind === SyntaxKind.PropertyAccessExpression) { var symbol = typeInfoResolver.getSymbolInfo(node); // This is an alias, follow what it aliases @@ -2412,7 +2412,7 @@ module ts { if (symbol && symbol.flags & SymbolFlags.HasExports) { // Extract module or enum members forEachValue(symbol.exports, symbol => { - if (typeInfoResolver.isValidPropertyAccess((node.parent), symbol.name)) { + if (typeInfoResolver.isValidPropertyAccess((node.parent), symbol.name)) { symbols.push(symbol); } }); @@ -2423,7 +2423,7 @@ module ts { if (type) { // Filter private properties forEach(type.getApparentProperties(), symbol => { - if (typeInfoResolver.isValidPropertyAccess((node.parent), symbol.name)) { + if (typeInfoResolver.isValidPropertyAccess((node.parent), symbol.name)) { symbols.push(symbol); } }); @@ -2542,7 +2542,7 @@ module ts { return false; } - function getContainingObjectLiteralApplicableForCompletion(previousToken: Node): ObjectLiteral { + function getContainingObjectLiteralApplicableForCompletion(previousToken: Node): ObjectLiteralExpression { // The locations in an object literal expression that are applicable for completion are property name definition locations. if (previousToken) { @@ -2551,8 +2551,8 @@ module ts { switch (previousToken.kind) { case SyntaxKind.OpenBraceToken: // var x = { | case SyntaxKind.CommaToken: // var x = { a: 0, | - if (parent && parent.kind === SyntaxKind.ObjectLiteral) { - return parent; + if (parent && parent.kind === SyntaxKind.ObjectLiteralExpression) { + return parent; } break; } @@ -2878,8 +2878,8 @@ module ts { var type = typeResolver.getNarrowedTypeOfSymbol(symbol, location); if (type) { - if (location.parent && location.parent.kind === SyntaxKind.PropertyAccess) { - var right = (location.parent).right; + if (location.parent && location.parent.kind === SyntaxKind.PropertyAccessExpression) { + var right = (location.parent).right; // Either the location is on the right of a property access, or on the left and the right is missing if (right === location || (right && right.kind === SyntaxKind.Missing)){ location = location.parent; @@ -3201,7 +3201,7 @@ module ts { // Try getting just type at this position and show switch (node.kind) { case SyntaxKind.Identifier: - case SyntaxKind.PropertyAccess: + case SyntaxKind.PropertyAccessExpression: case SyntaxKind.QualifiedName: case SyntaxKind.ThisKeyword: case SyntaxKind.SuperKeyword: @@ -4574,7 +4574,7 @@ module ts { var parent = node.parent; if (parent) { - if (parent.kind === SyntaxKind.PostfixOperator || parent.kind === SyntaxKind.PrefixUnaryExpression) { + if (parent.kind === SyntaxKind.PostfixUnaryExpression || parent.kind === SyntaxKind.PrefixUnaryExpression) { return true; } else if (parent.kind === SyntaxKind.BinaryExpression && (parent).left === node) { @@ -4879,7 +4879,7 @@ module ts { } switch (node.kind) { - case SyntaxKind.PropertyAccess: + case SyntaxKind.PropertyAccessExpression: case SyntaxKind.QualifiedName: case SyntaxKind.StringLiteral: case SyntaxKind.FalseKeyword: @@ -5064,7 +5064,7 @@ module ts { if (token.parent.kind === SyntaxKind.BinaryExpression || token.parent.kind === SyntaxKind.VariableDeclaration || token.parent.kind === SyntaxKind.PrefixUnaryExpression || - token.parent.kind === SyntaxKind.PostfixOperator || + token.parent.kind === SyntaxKind.PostfixUnaryExpression || token.parent.kind === SyntaxKind.ConditionalExpression) { return ClassificationTypeNames.operator; } diff --git a/src/services/smartIndenter.ts b/src/services/smartIndenter.ts index e593c6cfd66..3fbfe142282 100644 --- a/src/services/smartIndenter.ts +++ b/src/services/smartIndenter.ts @@ -227,10 +227,10 @@ module ts.formatting { return (node.parent).typeArguments; } break; - case SyntaxKind.ObjectLiteral: - return (node.parent).properties; - case SyntaxKind.ArrayLiteral: - return (node.parent).elements; + case SyntaxKind.ObjectLiteralExpression: + return (node.parent).properties; + case SyntaxKind.ArrayLiteralExpression: + return (node.parent).elements; case SyntaxKind.FunctionDeclaration: case SyntaxKind.FunctionExpression: case SyntaxKind.ArrowFunction: @@ -323,19 +323,19 @@ module ts.formatting { case SyntaxKind.ClassDeclaration: case SyntaxKind.InterfaceDeclaration: case SyntaxKind.EnumDeclaration: - case SyntaxKind.ArrayLiteral: + case SyntaxKind.ArrayLiteralExpression: case SyntaxKind.Block: case SyntaxKind.FunctionBlock: case SyntaxKind.TryBlock: case SyntaxKind.CatchBlock: case SyntaxKind.FinallyBlock: case SyntaxKind.ModuleBlock: - case SyntaxKind.ObjectLiteral: + case SyntaxKind.ObjectLiteralExpression: case SyntaxKind.TypeLiteral: case SyntaxKind.SwitchStatement: case SyntaxKind.DefaultClause: case SyntaxKind.CaseClause: - case SyntaxKind.ParenExpression: + case SyntaxKind.ParenthesizedExpression: case SyntaxKind.CallExpression: case SyntaxKind.NewExpression: case SyntaxKind.VariableStatement: @@ -397,7 +397,7 @@ module ts.formatting { case SyntaxKind.ClassDeclaration: case SyntaxKind.InterfaceDeclaration: case SyntaxKind.EnumDeclaration: - case SyntaxKind.ObjectLiteral: + case SyntaxKind.ObjectLiteralExpression: case SyntaxKind.Block: case SyntaxKind.CatchBlock: case SyntaxKind.FinallyBlock: @@ -405,7 +405,7 @@ module ts.formatting { case SyntaxKind.ModuleBlock: case SyntaxKind.SwitchStatement: return nodeEndsWith(n, SyntaxKind.CloseBraceToken, sourceFile); - case SyntaxKind.ParenExpression: + case SyntaxKind.ParenthesizedExpression: case SyntaxKind.CallSignature: case SyntaxKind.CallExpression: case SyntaxKind.ConstructSignature: @@ -424,7 +424,7 @@ module ts.formatting { return isCompletedNode((n).thenStatement, sourceFile); case SyntaxKind.ExpressionStatement: return isCompletedNode((n).expression, sourceFile); - case SyntaxKind.ArrayLiteral: + case SyntaxKind.ArrayLiteralExpression: return nodeEndsWith(n, SyntaxKind.CloseBracketToken, sourceFile); case SyntaxKind.Missing: return false;