Merge branch 'master' into expressionCleanup

This commit is contained in:
Cyrus Najmabadi
2014-11-30 20:14:02 -08:00
20 changed files with 251 additions and 328 deletions
+1 -1
View File
@@ -1489,7 +1489,7 @@ interface Uint32Array extends ArrayBufferView {
set(array: number[], offset?: number): void;
/**
* Gets a new Int8Array view of the ArrayBuffer Object store for this array, specifying the first and last members of the subarray.
* Gets a new Uint32Array view of the ArrayBuffer Object store for this array, specifying the first and last members of the subarray.
* @param begin The index of the beginning of the array.
* @param end The index of the end of the array.
*/
View File
View File
View File
-3
View File
@@ -6,9 +6,6 @@
/////<reference path='document.ts' />
/////<reference path='flags.ts' />
/////<reference path='hashTable.ts' />
/////<reference path='ast.ts' />
/////<reference path='astHelpers.ts' />
/////<reference path='astWalker.ts' />
/////<reference path='base64.ts' />
/////<reference path='sourceMapping.ts' />
/////<reference path='emitter.ts' />
+81 -82
View File
@@ -552,83 +552,82 @@ var TypeScript;
SyntaxKind[SyntaxKind["EnumDeclaration"] = 140] = "EnumDeclaration";
SyntaxKind[SyntaxKind["ImportDeclaration"] = 141] = "ImportDeclaration";
SyntaxKind[SyntaxKind["ExportAssignment"] = 142] = "ExportAssignment";
SyntaxKind[SyntaxKind["MemberFunctionDeclaration"] = 143] = "MemberFunctionDeclaration";
SyntaxKind[SyntaxKind["MemberVariableDeclaration"] = 144] = "MemberVariableDeclaration";
SyntaxKind[SyntaxKind["MethodDeclaration"] = 143] = "MethodDeclaration";
SyntaxKind[SyntaxKind["PropertyDeclaration"] = 144] = "PropertyDeclaration";
SyntaxKind[SyntaxKind["ConstructorDeclaration"] = 145] = "ConstructorDeclaration";
SyntaxKind[SyntaxKind["IndexMemberDeclaration"] = 146] = "IndexMemberDeclaration";
SyntaxKind[SyntaxKind["GetAccessor"] = 147] = "GetAccessor";
SyntaxKind[SyntaxKind["SetAccessor"] = 148] = "SetAccessor";
SyntaxKind[SyntaxKind["PropertySignature"] = 149] = "PropertySignature";
SyntaxKind[SyntaxKind["CallSignature"] = 150] = "CallSignature";
SyntaxKind[SyntaxKind["ConstructSignature"] = 151] = "ConstructSignature";
SyntaxKind[SyntaxKind["IndexSignature"] = 152] = "IndexSignature";
SyntaxKind[SyntaxKind["MethodSignature"] = 153] = "MethodSignature";
SyntaxKind[SyntaxKind["Block"] = 154] = "Block";
SyntaxKind[SyntaxKind["IfStatement"] = 155] = "IfStatement";
SyntaxKind[SyntaxKind["VariableStatement"] = 156] = "VariableStatement";
SyntaxKind[SyntaxKind["ExpressionStatement"] = 157] = "ExpressionStatement";
SyntaxKind[SyntaxKind["ReturnStatement"] = 158] = "ReturnStatement";
SyntaxKind[SyntaxKind["SwitchStatement"] = 159] = "SwitchStatement";
SyntaxKind[SyntaxKind["BreakStatement"] = 160] = "BreakStatement";
SyntaxKind[SyntaxKind["ContinueStatement"] = 161] = "ContinueStatement";
SyntaxKind[SyntaxKind["ForStatement"] = 162] = "ForStatement";
SyntaxKind[SyntaxKind["ForInStatement"] = 163] = "ForInStatement";
SyntaxKind[SyntaxKind["EmptyStatement"] = 164] = "EmptyStatement";
SyntaxKind[SyntaxKind["ThrowStatement"] = 165] = "ThrowStatement";
SyntaxKind[SyntaxKind["WhileStatement"] = 166] = "WhileStatement";
SyntaxKind[SyntaxKind["TryStatement"] = 167] = "TryStatement";
SyntaxKind[SyntaxKind["LabeledStatement"] = 168] = "LabeledStatement";
SyntaxKind[SyntaxKind["DoStatement"] = 169] = "DoStatement";
SyntaxKind[SyntaxKind["DebuggerStatement"] = 170] = "DebuggerStatement";
SyntaxKind[SyntaxKind["WithStatement"] = 171] = "WithStatement";
SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 172] = "PrefixUnaryExpression";
SyntaxKind[SyntaxKind["DeleteExpression"] = 173] = "DeleteExpression";
SyntaxKind[SyntaxKind["TypeOfExpression"] = 174] = "TypeOfExpression";
SyntaxKind[SyntaxKind["VoidExpression"] = 175] = "VoidExpression";
SyntaxKind[SyntaxKind["ConditionalExpression"] = 176] = "ConditionalExpression";
SyntaxKind[SyntaxKind["BinaryExpression"] = 177] = "BinaryExpression";
SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 178] = "PostfixUnaryExpression";
SyntaxKind[SyntaxKind["MemberAccessExpression"] = 179] = "MemberAccessExpression";
SyntaxKind[SyntaxKind["InvocationExpression"] = 180] = "InvocationExpression";
SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 181] = "ArrayLiteralExpression";
SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 182] = "ObjectLiteralExpression";
SyntaxKind[SyntaxKind["ObjectCreationExpression"] = 183] = "ObjectCreationExpression";
SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 184] = "ParenthesizedExpression";
SyntaxKind[SyntaxKind["ParenthesizedArrowFunctionExpression"] = 185] = "ParenthesizedArrowFunctionExpression";
SyntaxKind[SyntaxKind["SimpleArrowFunctionExpression"] = 186] = "SimpleArrowFunctionExpression";
SyntaxKind[SyntaxKind["CastExpression"] = 187] = "CastExpression";
SyntaxKind[SyntaxKind["ElementAccessExpression"] = 188] = "ElementAccessExpression";
SyntaxKind[SyntaxKind["FunctionExpression"] = 189] = "FunctionExpression";
SyntaxKind[SyntaxKind["OmittedExpression"] = 190] = "OmittedExpression";
SyntaxKind[SyntaxKind["TemplateExpression"] = 191] = "TemplateExpression";
SyntaxKind[SyntaxKind["TemplateAccessExpression"] = 192] = "TemplateAccessExpression";
SyntaxKind[SyntaxKind["YieldExpression"] = 193] = "YieldExpression";
SyntaxKind[SyntaxKind["AwaitExpression"] = 194] = "AwaitExpression";
SyntaxKind[SyntaxKind["VariableDeclaration"] = 195] = "VariableDeclaration";
SyntaxKind[SyntaxKind["VariableDeclarator"] = 196] = "VariableDeclarator";
SyntaxKind[SyntaxKind["ArgumentList"] = 197] = "ArgumentList";
SyntaxKind[SyntaxKind["ParameterList"] = 198] = "ParameterList";
SyntaxKind[SyntaxKind["TypeArgumentList"] = 199] = "TypeArgumentList";
SyntaxKind[SyntaxKind["TypeParameterList"] = 200] = "TypeParameterList";
SyntaxKind[SyntaxKind["HeritageClause"] = 201] = "HeritageClause";
SyntaxKind[SyntaxKind["EqualsValueClause"] = 202] = "EqualsValueClause";
SyntaxKind[SyntaxKind["CaseSwitchClause"] = 203] = "CaseSwitchClause";
SyntaxKind[SyntaxKind["DefaultSwitchClause"] = 204] = "DefaultSwitchClause";
SyntaxKind[SyntaxKind["ElseClause"] = 205] = "ElseClause";
SyntaxKind[SyntaxKind["CatchClause"] = 206] = "CatchClause";
SyntaxKind[SyntaxKind["FinallyClause"] = 207] = "FinallyClause";
SyntaxKind[SyntaxKind["TemplateClause"] = 208] = "TemplateClause";
SyntaxKind[SyntaxKind["TypeParameter"] = 209] = "TypeParameter";
SyntaxKind[SyntaxKind["Constraint"] = 210] = "Constraint";
SyntaxKind[SyntaxKind["Parameter"] = 211] = "Parameter";
SyntaxKind[SyntaxKind["EnumElement"] = 212] = "EnumElement";
SyntaxKind[SyntaxKind["TypeAnnotation"] = 213] = "TypeAnnotation";
SyntaxKind[SyntaxKind["ExpressionBody"] = 214] = "ExpressionBody";
SyntaxKind[SyntaxKind["ComputedPropertyName"] = 215] = "ComputedPropertyName";
SyntaxKind[SyntaxKind["PropertyAssignment"] = 216] = "PropertyAssignment";
SyntaxKind[SyntaxKind["TypeAlias"] = 217] = "TypeAlias";
SyntaxKind[SyntaxKind["ExternalModuleReference"] = 218] = "ExternalModuleReference";
SyntaxKind[SyntaxKind["ModuleNameModuleReference"] = 219] = "ModuleNameModuleReference";
SyntaxKind[SyntaxKind["GetAccessor"] = 146] = "GetAccessor";
SyntaxKind[SyntaxKind["SetAccessor"] = 147] = "SetAccessor";
SyntaxKind[SyntaxKind["PropertySignature"] = 148] = "PropertySignature";
SyntaxKind[SyntaxKind["CallSignature"] = 149] = "CallSignature";
SyntaxKind[SyntaxKind["ConstructSignature"] = 150] = "ConstructSignature";
SyntaxKind[SyntaxKind["IndexSignature"] = 151] = "IndexSignature";
SyntaxKind[SyntaxKind["MethodSignature"] = 152] = "MethodSignature";
SyntaxKind[SyntaxKind["Block"] = 153] = "Block";
SyntaxKind[SyntaxKind["IfStatement"] = 154] = "IfStatement";
SyntaxKind[SyntaxKind["VariableStatement"] = 155] = "VariableStatement";
SyntaxKind[SyntaxKind["ExpressionStatement"] = 156] = "ExpressionStatement";
SyntaxKind[SyntaxKind["ReturnStatement"] = 157] = "ReturnStatement";
SyntaxKind[SyntaxKind["SwitchStatement"] = 158] = "SwitchStatement";
SyntaxKind[SyntaxKind["BreakStatement"] = 159] = "BreakStatement";
SyntaxKind[SyntaxKind["ContinueStatement"] = 160] = "ContinueStatement";
SyntaxKind[SyntaxKind["ForStatement"] = 161] = "ForStatement";
SyntaxKind[SyntaxKind["ForInStatement"] = 162] = "ForInStatement";
SyntaxKind[SyntaxKind["EmptyStatement"] = 163] = "EmptyStatement";
SyntaxKind[SyntaxKind["ThrowStatement"] = 164] = "ThrowStatement";
SyntaxKind[SyntaxKind["WhileStatement"] = 165] = "WhileStatement";
SyntaxKind[SyntaxKind["TryStatement"] = 166] = "TryStatement";
SyntaxKind[SyntaxKind["LabeledStatement"] = 167] = "LabeledStatement";
SyntaxKind[SyntaxKind["DoStatement"] = 168] = "DoStatement";
SyntaxKind[SyntaxKind["DebuggerStatement"] = 169] = "DebuggerStatement";
SyntaxKind[SyntaxKind["WithStatement"] = 170] = "WithStatement";
SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 171] = "PrefixUnaryExpression";
SyntaxKind[SyntaxKind["DeleteExpression"] = 172] = "DeleteExpression";
SyntaxKind[SyntaxKind["TypeOfExpression"] = 173] = "TypeOfExpression";
SyntaxKind[SyntaxKind["VoidExpression"] = 174] = "VoidExpression";
SyntaxKind[SyntaxKind["ConditionalExpression"] = 175] = "ConditionalExpression";
SyntaxKind[SyntaxKind["BinaryExpression"] = 176] = "BinaryExpression";
SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 177] = "PostfixUnaryExpression";
SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 178] = "PropertyAccessExpression";
SyntaxKind[SyntaxKind["InvocationExpression"] = 179] = "InvocationExpression";
SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 180] = "ArrayLiteralExpression";
SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 181] = "ObjectLiteralExpression";
SyntaxKind[SyntaxKind["ObjectCreationExpression"] = 182] = "ObjectCreationExpression";
SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 183] = "ParenthesizedExpression";
SyntaxKind[SyntaxKind["ParenthesizedArrowFunctionExpression"] = 184] = "ParenthesizedArrowFunctionExpression";
SyntaxKind[SyntaxKind["SimpleArrowFunctionExpression"] = 185] = "SimpleArrowFunctionExpression";
SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 186] = "TypeAssertionExpression";
SyntaxKind[SyntaxKind["ElementAccessExpression"] = 187] = "ElementAccessExpression";
SyntaxKind[SyntaxKind["FunctionExpression"] = 188] = "FunctionExpression";
SyntaxKind[SyntaxKind["OmittedExpression"] = 189] = "OmittedExpression";
SyntaxKind[SyntaxKind["TemplateExpression"] = 190] = "TemplateExpression";
SyntaxKind[SyntaxKind["TemplateAccessExpression"] = 191] = "TemplateAccessExpression";
SyntaxKind[SyntaxKind["YieldExpression"] = 192] = "YieldExpression";
SyntaxKind[SyntaxKind["AwaitExpression"] = 193] = "AwaitExpression";
SyntaxKind[SyntaxKind["VariableDeclaration"] = 194] = "VariableDeclaration";
SyntaxKind[SyntaxKind["VariableDeclarator"] = 195] = "VariableDeclarator";
SyntaxKind[SyntaxKind["ArgumentList"] = 196] = "ArgumentList";
SyntaxKind[SyntaxKind["ParameterList"] = 197] = "ParameterList";
SyntaxKind[SyntaxKind["TypeArgumentList"] = 198] = "TypeArgumentList";
SyntaxKind[SyntaxKind["TypeParameterList"] = 199] = "TypeParameterList";
SyntaxKind[SyntaxKind["HeritageClause"] = 200] = "HeritageClause";
SyntaxKind[SyntaxKind["EqualsValueClause"] = 201] = "EqualsValueClause";
SyntaxKind[SyntaxKind["CaseSwitchClause"] = 202] = "CaseSwitchClause";
SyntaxKind[SyntaxKind["DefaultSwitchClause"] = 203] = "DefaultSwitchClause";
SyntaxKind[SyntaxKind["ElseClause"] = 204] = "ElseClause";
SyntaxKind[SyntaxKind["CatchClause"] = 205] = "CatchClause";
SyntaxKind[SyntaxKind["FinallyClause"] = 206] = "FinallyClause";
SyntaxKind[SyntaxKind["TemplateClause"] = 207] = "TemplateClause";
SyntaxKind[SyntaxKind["TypeParameter"] = 208] = "TypeParameter";
SyntaxKind[SyntaxKind["Constraint"] = 209] = "Constraint";
SyntaxKind[SyntaxKind["Parameter"] = 210] = "Parameter";
SyntaxKind[SyntaxKind["EnumElement"] = 211] = "EnumElement";
SyntaxKind[SyntaxKind["TypeAnnotation"] = 212] = "TypeAnnotation";
SyntaxKind[SyntaxKind["ExpressionBody"] = 213] = "ExpressionBody";
SyntaxKind[SyntaxKind["ComputedPropertyName"] = 214] = "ComputedPropertyName";
SyntaxKind[SyntaxKind["PropertyAssignment"] = 215] = "PropertyAssignment";
SyntaxKind[SyntaxKind["TypeAlias"] = 216] = "TypeAlias";
SyntaxKind[SyntaxKind["ExternalModuleReference"] = 217] = "ExternalModuleReference";
SyntaxKind[SyntaxKind["ModuleNameModuleReference"] = 218] = "ModuleNameModuleReference";
SyntaxKind[SyntaxKind["FirstStandardKeyword"] = 17] = "FirstStandardKeyword";
SyntaxKind[SyntaxKind["LastStandardKeyword"] = 45] = "LastStandardKeyword";
SyntaxKind[SyntaxKind["FirstFutureReservedKeyword"] = 46] = "FirstFutureReservedKeyword";
@@ -648,7 +647,7 @@ var TypeScript;
SyntaxKind[SyntaxKind["FirstTrivia"] = 2] = "FirstTrivia";
SyntaxKind[SyntaxKind["LastTrivia"] = 6] = "LastTrivia";
SyntaxKind[SyntaxKind["FirstNode"] = 125] = "FirstNode";
SyntaxKind[SyntaxKind["LastNode"] = 219] = "LastNode";
SyntaxKind[SyntaxKind["LastNode"] = 218] = "LastNode";
})(TypeScript.SyntaxKind || (TypeScript.SyntaxKind = {}));
var SyntaxKind = TypeScript.SyntaxKind;
})(TypeScript || (TypeScript = {}));
@@ -1298,7 +1297,7 @@ var definitions = [
]
},
{
name: 'MemberAccessExpressionSyntax',
name: 'PropertyAccessExpressionSyntax',
baseType: 'ISyntaxNode',
interfaces: ['IMemberExpressionSyntax', 'ICallExpressionSyntax'],
children: [
@@ -1531,7 +1530,7 @@ var definitions = [
isTypeScriptSpecific: true
},
{
name: 'MemberFunctionDeclarationSyntax',
name: 'MethodDeclarationSyntax',
baseType: 'ISyntaxNode',
interfaces: ['IMemberDeclarationSyntax', 'IPropertyAssignmentSyntax'],
children: [
@@ -1569,7 +1568,7 @@ var definitions = [
isTypeScriptSpecific: true
},
{
name: 'MemberVariableDeclarationSyntax',
name: 'PropertyDeclarationSyntax',
baseType: 'ISyntaxNode',
interfaces: ['IMemberDeclarationSyntax'],
children: [
@@ -1741,7 +1740,7 @@ var definitions = [
]
},
{
name: 'CastExpressionSyntax',
name: 'TypeAssertionExpressionSyntax',
baseType: 'ISyntaxNode',
interfaces: ['IUnaryExpressionSyntax'],
children: [
@@ -1901,7 +1900,7 @@ var definitions = [
interfaces: ['IUnaryExpressionSyntax'],
children: [
{ name: 'awaitKeyword', isToken: true },
{ name: 'expression', type: 'IExpressionSyntax', isOptional: true }
{ name: 'expression', type: 'IUnaryExpressionSyntax', isOptional: true }
]
},
{
File diff suppressed because one or more lines are too long
+91 -129
View File
@@ -993,7 +993,7 @@ module TypeScript.Parser {
return tryParseName(allowIdentifierName) || eatIdentifierToken();
}
function eatRightSideOfName(allowIdentifierNames: boolean): ISyntaxToken {
function eatRightSideOfDot(allowIdentifierNames: boolean): ISyntaxToken {
var _currentToken = currentToken();
// Technically a keyword is valid here as all keywords are identifier names.
@@ -1019,7 +1019,7 @@ module TypeScript.Parser {
_currentToken.hasLeadingNewLine()) {
var token1 = peekToken(1);
if (!existsNewLineBetweenTokens(_currentToken, token1, source.text) &&
if (!token1.hasLeadingNewLine() &&
SyntaxFacts.isIdentifierNameOrAnyKeyword(token1)) {
return createMissingToken(SyntaxKind.IdentifierName, _currentToken);
@@ -1041,7 +1041,7 @@ module TypeScript.Parser {
while (shouldContinue && currentToken().kind === SyntaxKind.DotToken) {
var dotToken = consumeToken(currentToken());
var identifierName = eatRightSideOfName(allowIdentifierNames);
var identifierName = eatRightSideOfDot(allowIdentifierNames);
current = new QualifiedNameSyntax(contextFlags, current, dotToken, identifierName);
shouldContinue = identifierName.fullWidth() > 0;
@@ -1375,10 +1375,10 @@ module TypeScript.Parser {
// if we have a call signature. If so, then this is a member function, otherwise
// it's a member variable.
if (asterixToken || isCallSignature(/*peekIndex:*/ 0)) {
return parseMemberFunctionDeclaration(modifiers, asterixToken, propertyName);
return parseMethodDeclaration(modifiers, asterixToken, propertyName);
}
else {
return parseMemberVariableDeclaration(modifiers, propertyName);
return parsePropertyDeclaration(modifiers, propertyName);
}
}
else {
@@ -1405,13 +1405,13 @@ module TypeScript.Parser {
parseFunctionBody(/*isGenerator:*/ false, /*asyncContext:*/ false));
}
function parseMemberFunctionDeclaration(modifiers: ISyntaxToken[], asteriskToken: ISyntaxToken, propertyName: IPropertyNameSyntax): MemberFunctionDeclarationSyntax {
function parseMethodDeclaration(modifiers: ISyntaxToken[], asteriskToken: ISyntaxToken, propertyName: IPropertyNameSyntax): MethodDeclarationSyntax {
// Note: if we see an arrow after the close paren, then try to parse out a function
// block anyways. It's likely the user just though '=> expr' was legal anywhere a
// block was legal.
var asyncContext = containsAsync(modifiers);
var isGenerator = asteriskToken !== undefined;
return new MemberFunctionDeclarationSyntax(contextFlags,
return new MethodDeclarationSyntax(contextFlags,
modifiers,
asteriskToken,
propertyName,
@@ -1429,8 +1429,8 @@ module TypeScript.Parser {
return false;
}
function parseMemberVariableDeclaration(modifiers: ISyntaxToken[], propertyName: IPropertyNameSyntax): MemberVariableDeclarationSyntax {
return new MemberVariableDeclarationSyntax(contextFlags,
function parsePropertyDeclaration(modifiers: ISyntaxToken[], propertyName: IPropertyNameSyntax): PropertyDeclarationSyntax {
return new PropertyDeclarationSyntax(contextFlags,
modifiers,
new VariableDeclaratorSyntax(contextFlags, propertyName,
parseOptionalTypeAnnotation(/*allowStringLiteral:*/ false),
@@ -1555,8 +1555,7 @@ module TypeScript.Parser {
// Then we *should* parse it as a property name, as ASI takes effect here.
if (isModifier(_currentToken, /*index:*/ 0)) {
var token1 = peekToken(1);
if (!existsNewLineBetweenTokens(_currentToken, token1, source.text) &&
isPropertyNameToken(token1, inErrorRecovery)) {
if (!token1.hasLeadingNewLine() && isPropertyNameToken(token1, inErrorRecovery)) {
return false;
}
@@ -2238,7 +2237,7 @@ module TypeScript.Parser {
return new OmittedExpressionSyntax(contextFlags);
}
return allowInAnd(tryParseAssignmentExpressionOrHigher);
return isExpression(currentToken()) ? allowInAnd(parseAssignmentExpressionOrHigher) : undefined;
}
function isExpression(currentToken: ISyntaxToken): boolean {
@@ -2521,19 +2520,11 @@ module TypeScript.Parser {
return leftOperand;
}
function tryParseAssignmentExpressionOrHigher(): IExpressionSyntax {
return tryParseAssignmentExpressionOrHigherWorker(/*force:*/ false);
}
function parseAssignmentExpressionOrHigher(): IExpressionSyntax {
return tryParseAssignmentExpressionOrHigherWorker(/*force:*/ true);
}
// Called when you need to parse an expression, but you do not want to allow 'CommaExpressions'.
// i.e. if you have "var a = 1, b = 2" then when we parse '1' we want to parse with higher
// precedence than 'comma'. Otherwise we'll get: "var a = (1, (b = 2))", instead of
// "var a = (1), b = (2)");
function tryParseAssignmentExpressionOrHigherWorker(force: boolean): IExpressionSyntax {
function parseAssignmentExpressionOrHigher(): IExpressionSyntax {
// AssignmentExpression[in,yield]:
// 1) ConditionalExpression[?in,?yield]
// 2) LeftHandSideExpression = AssignmentExpression[?in,?yield]
@@ -2567,11 +2558,7 @@ module TypeScript.Parser {
// Otherwise, we try to parse out the conditional expression bit. We want to allow any
// binary expression here, so we pass in the 'lowest' precedence here so that it matches
// and consumes anything.
var leftOperand = tryParseBinaryExpressionOrHigher(_currentToken, force, BinaryExpressionPrecedence.Lowest);
if (leftOperand === undefined) {
return undefined;
}
var leftOperand = parseBinaryExpressionOrHigher(_currentToken, BinaryExpressionPrecedence.Lowest);
if (SyntaxUtilities.isLeftHandSizeExpression(leftOperand)) {
// Note: we call currentOperatorToken so that we get an appropriately merged token
// for cases like > > = becoming >>=
@@ -2615,13 +2602,13 @@ module TypeScript.Parser {
}
// Not an 'await' expression. Parse this with our normal postfix parsing rules.
return tryParsePostfixExpressionOrHigher(awaitKeyword, /*force:*/ true);
return parsePostfixExpressionOrHigher(awaitKeyword);
}
function parseAwaitExpression(awaitKeyword: ISyntaxToken): AwaitExpressionSyntax {
return new AwaitExpressionSyntax(contextFlags,
consumeToken(awaitKeyword),
parseAssignmentExpressionOrHigher());
parseUnaryExpressionOrHigher(currentToken()));
}
function isYieldExpression(_currentToken: ISyntaxToken): boolean {
@@ -2728,7 +2715,7 @@ module TypeScript.Parser {
: tryParseParenthesizedArrowFunctionExpression();
}
function tryParseUnaryExpressionOrHigher(_currentToken: ISyntaxToken, force: boolean): IUnaryExpressionSyntax {
function parseUnaryExpressionOrHigher(_currentToken: ISyntaxToken): IUnaryExpressionSyntax {
var currentTokenKind = _currentToken.kind;
switch (currentTokenKind) {
@@ -2738,7 +2725,7 @@ module TypeScript.Parser {
case SyntaxKind.ExclamationToken:
case SyntaxKind.PlusPlusToken:
case SyntaxKind.MinusMinusToken:
return new PrefixUnaryExpressionSyntax(contextFlags, consumeToken(_currentToken), tryParseUnaryExpressionOrHigher(currentToken(), /*force:*/ true));
return new PrefixUnaryExpressionSyntax(contextFlags, consumeToken(_currentToken), parseUnaryExpressionOrHigher(currentToken()));
case SyntaxKind.TypeOfKeyword:
return parseTypeOfExpression(_currentToken);
case SyntaxKind.VoidKeyword:
@@ -2746,15 +2733,15 @@ module TypeScript.Parser {
case SyntaxKind.DeleteKeyword:
return parseDeleteExpression(_currentToken);
case SyntaxKind.LessThanToken:
return parseCastExpression(_currentToken);
return parseTypeAssertionExpression(_currentToken);
case SyntaxKind.AwaitKeyword:
return parsePossibleAwaitExpression(_currentToken);
default:
return tryParsePostfixExpressionOrHigher(_currentToken, force);
return parsePostfixExpressionOrHigher(_currentToken);
}
}
function tryParseBinaryExpressionOrHigher(_currentToken: ISyntaxToken, force: boolean, precedence: BinaryExpressionPrecedence): IExpressionSyntax {
function parseBinaryExpressionOrHigher(_currentToken: ISyntaxToken, precedence: BinaryExpressionPrecedence): IExpressionSyntax {
// The binary expressions are incredibly left recursive in their definitions. We
// clearly can't implement that through recursion. So, instead, we first bottom out
// of all the recursion by jumping to this production and consuming a UnaryExpression
@@ -2762,10 +2749,7 @@ module TypeScript.Parser {
//
// MultiplicativeExpression: See 11.5
// UnaryExpression
var leftOperand = tryParseUnaryExpressionOrHigher(_currentToken, force);
if (leftOperand === undefined) {
return undefined;
}
var leftOperand = parseUnaryExpressionOrHigher(_currentToken);
// We then pop up the stack consuming the other side of the binary exprssion if it exists.
return parseBinaryExpressionRest(precedence, leftOperand);
@@ -2829,7 +2813,7 @@ module TypeScript.Parser {
// Now skip the operator token we're on.
leftOperand = new BinaryExpressionSyntax(contextFlags, leftOperand, consumeToken(operatorToken),
tryParseBinaryExpressionOrHigher(currentToken(), /*force:*/ true, newPrecedence));
parseBinaryExpressionOrHigher(currentToken(), newPrecedence));
}
return leftOperand;
@@ -2851,7 +2835,7 @@ module TypeScript.Parser {
return token0;
}
function tryParseMemberExpressionOrHigher(_currentToken: ISyntaxToken, force: boolean): IMemberExpressionSyntax {
function parseMemberExpressionOrHigher(_currentToken: ISyntaxToken): IMemberExpressionSyntax {
// Note: to make our lives simpler, we decompose the the NewExpression productions and
// place ObjectCreationExpression and FunctionExpression into PrimaryExpression.
// like so:
@@ -2899,16 +2883,41 @@ module TypeScript.Parser {
//
// Because CallExpression and MemberExpression are left recursive, we need to bottom out
// of the recursion immediately. So we parse out a primary expression to start with.
var expression: IMemberExpressionSyntax = tryParsePrimaryExpression(_currentToken, force);
if (expression === undefined) {
return undefined;
}
var expression = parsePrimaryExpression(_currentToken);
return <IMemberExpressionSyntax>parseMemberExpressionRest(expression);
}
return parseMemberExpressionRest(expression);
function parseMemberExpressionRest(expression: ILeftHandSideExpressionSyntax): ILeftHandSideExpressionSyntax {
while (true) {
var _currentToken = currentToken();
var currentTokenKind = _currentToken.kind;
switch (currentTokenKind) {
case SyntaxKind.OpenBracketToken:
expression = parseElementAccessExpression(expression, _currentToken);
continue;
case SyntaxKind.DotToken:
expression = new PropertyAccessExpressionSyntax(contextFlags,
expression,
consumeToken(_currentToken),
eatRightSideOfDot(/*allowIdentifierNames:*/ true));
continue;
case SyntaxKind.NoSubstitutionTemplateToken:
case SyntaxKind.TemplateStartToken:
expression = new TemplateAccessExpressionSyntax(contextFlags, expression, parseTemplateExpression(_currentToken));
continue;
}
return expression;
}
}
function parseCallExpressionRest(expression: ILeftHandSideExpressionSyntax): ILeftHandSideExpressionSyntax {
while (true) {
expression = parseMemberExpressionRest(expression);
var _currentToken = currentToken();
var currentTokenKind = _currentToken.kind;
@@ -2929,50 +2938,13 @@ module TypeScript.Parser {
expression = new InvocationExpressionSyntax(contextFlags, expression, argumentList);
continue;
case SyntaxKind.OpenBracketToken:
expression = parseElementAccessExpression(expression, _currentToken);
continue;
case SyntaxKind.DotToken:
expression = new MemberAccessExpressionSyntax(contextFlags, expression, consumeToken(_currentToken), eatIdentifierNameToken());
continue;
case SyntaxKind.NoSubstitutionTemplateToken:
case SyntaxKind.TemplateStartToken:
expression = new TemplateAccessExpressionSyntax(contextFlags, expression, parseTemplateExpression(_currentToken));
continue;
}
return expression;
}
}
function parseMemberExpressionRest(expression: IMemberExpressionSyntax): IMemberExpressionSyntax {
while (true) {
var _currentToken = currentToken();
var currentTokenKind = _currentToken.kind;
switch (currentTokenKind) {
case SyntaxKind.OpenBracketToken:
expression = parseElementAccessExpression(expression, _currentToken);
continue;
case SyntaxKind.DotToken:
expression = new MemberAccessExpressionSyntax(contextFlags, expression, consumeToken(_currentToken), eatIdentifierNameToken());
continue;
case SyntaxKind.NoSubstitutionTemplateToken:
case SyntaxKind.TemplateStartToken:
expression = new TemplateAccessExpressionSyntax(contextFlags, expression, parseTemplateExpression(_currentToken));
continue;
}
return expression;
}
}
function tryParseLeftHandSideExpressionOrHigher(_currentToken: ISyntaxToken, force: boolean): ILeftHandSideExpressionSyntax {
function parseLeftHandSideExpressionOrHigher(_currentToken: ISyntaxToken): ILeftHandSideExpressionSyntax {
// Original Ecma:
// LeftHandSideExpression: See 11.2
// NewExpression
@@ -3004,16 +2976,9 @@ module TypeScript.Parser {
// completes the LeftHandSideExpression, or starts the beginning of the first four
// CallExpression productions.
var expression: ILeftHandSideExpressionSyntax = undefined;
if (_currentToken.kind === SyntaxKind.SuperKeyword) {
expression = parseSuperExpression(_currentToken);
}
else {
expression = tryParseMemberExpressionOrHigher(_currentToken, force);
if (expression === undefined) {
return undefined;
}
}
var expression: ILeftHandSideExpressionSyntax = _currentToken.kind === SyntaxKind.SuperKeyword
? parseSuperExpression(_currentToken)
: parseMemberExpressionOrHigher(_currentToken);
// Now, we *may* be complete. However, we might have consumed the start of a
// CallExpression. As such, we need to consume the rest of it here to be complete.
@@ -3026,16 +2991,18 @@ module TypeScript.Parser {
// 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 currentTokenKind = currentToken().kind;
return currentTokenKind === SyntaxKind.OpenParenToken || currentTokenKind === SyntaxKind.DotToken
? expression
: new MemberAccessExpressionSyntax(contextFlags, expression, eatToken(SyntaxKind.DotToken), eatIdentifierNameToken());
if (currentTokenKind === SyntaxKind.OpenParenToken || currentTokenKind === SyntaxKind.DotToken) {
return expression;
}
return new PropertyAccessExpressionSyntax(contextFlags,
expression,
eatToken(SyntaxKind.DotToken),
eatRightSideOfDot(/*allowIdentifierNames:*/ true));
}
function tryParsePostfixExpressionOrHigher(_currentToken: ISyntaxToken, force: boolean): IPostfixExpressionSyntax {
var expression = tryParseLeftHandSideExpressionOrHigher(_currentToken, force);
if (expression === undefined) {
return undefined;
}
function parsePostfixExpressionOrHigher(_currentToken: ISyntaxToken): IPostfixExpressionSyntax {
var expression = parseLeftHandSideExpressionOrHigher(_currentToken);
var _currentToken = currentToken();
var currentTokenKind = _currentToken.kind;
@@ -3136,7 +3103,7 @@ module TypeScript.Parser {
// cause a missing identiifer to be created), so that we will then consume the
// comma and the following list items).
var force = currentToken().kind === SyntaxKind.CommaToken;
return allowInAnd(force ? parseAssignmentExpressionOrHigher : tryParseAssignmentExpressionOrHigher);
return (force || isExpression(currentToken())) ? allowInAnd(parseAssignmentExpressionOrHigher) : undefined;
}
function parseElementAccessArgumentExpression(openBracketToken: ISyntaxToken) {
@@ -3153,20 +3120,7 @@ module TypeScript.Parser {
parseElementAccessArgumentExpression(openBracketToken), eatToken(SyntaxKind.CloseBracketToken));
}
function tryParsePrimaryExpression(_currentToken: ISyntaxToken, force: boolean): IPrimaryExpressionSyntax {
// Have to check for 'async function' first as 'async' is an identifier and will be
// consumed immediately below this.
if (_currentToken.kind === SyntaxKind.AsyncKeyword) {
var token1 = peekToken(1);
if (!token1.hasLeadingNewLine() && token1.kind === SyntaxKind.FunctionKeyword) {
return parseFunctionExpression();
}
}
if (isIdentifier(_currentToken)) {
return eatIdentifierToken();
}
function parsePrimaryExpression(_currentToken: ISyntaxToken): IPrimaryExpressionSyntax {
var currentTokenKind = _currentToken.kind;
switch (currentTokenKind) {
case SyntaxKind.ThisKeyword:
@@ -3195,13 +3149,16 @@ module TypeScript.Parser {
// If we see a standalone / or /= and we're expecting an expression, then reparse
// it as a regular expression.
return reparseDivideAsRegularExpression();
case SyntaxKind.AsyncKeyword:
var token1 = peekToken(1);
if (!token1.hasLeadingNewLine() && token1.kind === SyntaxKind.FunctionKeyword) {
return parseFunctionExpression();
}
break;
}
if (!force) {
return undefined;
}
// Nothing else worked, report an error and produce a missing token.
// Nothing else worked. try to eat an identifier. If we can't, we'll report an
// appropriate error.
return eatIdentifierToken(DiagnosticCode.Expression_expected);
}
@@ -3228,15 +3185,15 @@ module TypeScript.Parser {
}
function parseTypeOfExpression(typeOfKeyword: ISyntaxToken): TypeOfExpressionSyntax {
return new TypeOfExpressionSyntax(contextFlags, consumeToken(typeOfKeyword), tryParseUnaryExpressionOrHigher(currentToken(), /*force:*/ true));
return new TypeOfExpressionSyntax(contextFlags, consumeToken(typeOfKeyword), parseUnaryExpressionOrHigher(currentToken()));
}
function parseDeleteExpression(deleteKeyword: ISyntaxToken): DeleteExpressionSyntax {
return new DeleteExpressionSyntax(contextFlags, consumeToken(deleteKeyword), tryParseUnaryExpressionOrHigher(currentToken(), /*force:*/ true));
return new DeleteExpressionSyntax(contextFlags, consumeToken(deleteKeyword), parseUnaryExpressionOrHigher(currentToken()));
}
function parseVoidExpression(voidKeyword: ISyntaxToken): VoidExpressionSyntax {
return new VoidExpressionSyntax(contextFlags, consumeToken(voidKeyword), tryParseUnaryExpressionOrHigher(currentToken(), /*force:*/ true));
return new VoidExpressionSyntax(contextFlags, consumeToken(voidKeyword), parseUnaryExpressionOrHigher(currentToken()));
}
function parseFunctionExpression(): FunctionExpressionSyntax {
@@ -3282,7 +3239,9 @@ module TypeScript.Parser {
// this decision.
return new ObjectCreationExpressionSyntax(contextFlags,
consumeToken(newKeyword), tryParseMemberExpressionOrHigher(currentToken(), /*force:*/ true), tryParseArgumentList());
consumeToken(newKeyword),
parseMemberExpressionOrHigher(currentToken()),
tryParseArgumentList());
}
function parseTemplateExpression(startToken: ISyntaxToken): IPrimaryExpressionSyntax {
@@ -3325,9 +3284,12 @@ module TypeScript.Parser {
return new TemplateClauseSyntax(contextFlags, expression, token);
}
function parseCastExpression(lessThanToken: ISyntaxToken): CastExpressionSyntax {
return new CastExpressionSyntax(contextFlags,
consumeToken(lessThanToken), parseType(), eatToken(SyntaxKind.GreaterThanToken), tryParseUnaryExpressionOrHigher(currentToken(), /*force:*/ true));
function parseTypeAssertionExpression(lessThanToken: ISyntaxToken): TypeAssertionExpressionSyntax {
return new TypeAssertionExpressionSyntax(contextFlags,
consumeToken(lessThanToken),
parseType(),
eatToken(SyntaxKind.GreaterThanToken),
parseUnaryExpressionOrHigher(currentToken()));
}
function parseParenthesizedExpression(openParenToken: ISyntaxToken): ParenthesizedExpressionSyntax {
@@ -3710,7 +3672,7 @@ module TypeScript.Parser {
var propertyName = parsePropertyName();
if (modifiers.length > 0 || asterixToken !== undefined || isCallSignature(/*peekIndex:*/ 0)) {
return parseMemberFunctionDeclaration(modifiers, asterixToken, propertyName);
return parseMethodDeclaration(modifiers, asterixToken, propertyName);
}
else {
// PropertyName[?Yield] : AssignmentExpression[In, ?Yield]
@@ -4044,7 +4006,7 @@ module TypeScript.Parser {
// We do not want the > to be consumed as part of the "" expression. By starting
// at 'unary' expression and not 'binary' expression, we ensure that we don't accidently
// consume the >.
return tryParseUnaryExpressionOrHigher(_currentToken, /*force:*/ true);
return parseUnaryExpressionOrHigher(_currentToken);
}
return eatIdentifierToken(DiagnosticCode.Type_expected);
+4 -4
View File
@@ -535,7 +535,7 @@ module TypeScript.PrettyPrinter {
this.appendNode(node.equalsValueClause);
}
public visitMemberAccessExpression(node: MemberAccessExpressionSyntax): void {
public visitPropertyAccessExpression(node: PropertyAccessExpressionSyntax): void {
visitNodeOrToken(this, node.expression);
this.appendToken(node.dotToken);
this.appendToken(node.name);
@@ -693,7 +693,7 @@ module TypeScript.PrettyPrinter {
this.appendBody(node.body);
}
public visitMemberFunctionDeclaration(node: MemberFunctionDeclarationSyntax): void {
public visitMethodDeclaration(node: MethodDeclarationSyntax): void {
this.appendSpaceList(node.modifiers);
this.ensureSpace();
visitNodeOrToken(this, node.propertyName);
@@ -723,7 +723,7 @@ module TypeScript.PrettyPrinter {
visitNodeOrToken(this, node.body);
}
public visitMemberVariableDeclaration(node: MemberVariableDeclarationSyntax): void {
public visitPropertyDeclaration(node: PropertyDeclarationSyntax): void {
this.appendSpaceList(node.modifiers);
this.ensureSpace();
visitNodeOrToken(this, node.variableDeclarator);
@@ -910,7 +910,7 @@ module TypeScript.PrettyPrinter {
this.appendNode(node.equalsValueClause);
}
public visitCastExpression(node: CastExpressionSyntax): void {
public visitTypeAssertionExpression(node: TypeAssertionExpressionSyntax): void {
this.appendToken(node.lessThanToken);
visitNodeOrToken(this, node.type);
this.appendToken(node.greaterThanToken);
-2
View File
@@ -34,8 +34,6 @@
// SyntaxInformationMap depends on SyntaxWalker
// ///<reference path='syntaxNodeInvariantsChecker.ts' />
// DepthLimitedWalker depends on PositionTrackingWalker
///<reference path='depthLimitedWalker.ts' />
///<reference path='parser.ts' />
// Concrete nodes depend on the parser.
-13
View File
@@ -371,19 +371,6 @@ module TypeScript {
return fullStart(element) + fullWidth(element);
}
export function existsNewLineBetweenTokens(token1: ISyntaxToken, token2: ISyntaxToken, text: ISimpleText) {
if (token1 === token2) {
return false;
}
if (!token1 || !token2) {
return true;
}
var lineMap = text.lineMap();
return lineMap.getLineNumberFromPosition(fullEnd(token1)) !== lineMap.getLineNumberFromPosition(start(token2, text));
}
export interface ISyntaxElement {
kind: SyntaxKind;
parent: ISyntaxElement;
+5 -5
View File
@@ -436,7 +436,7 @@ var definitions:ITypeDefinition[] = [
]
},
<any>{
name: 'MemberAccessExpressionSyntax',
name: 'PropertyAccessExpressionSyntax',
baseType: 'ISyntaxNode',
interfaces: ['IMemberExpressionSyntax', 'ICallExpressionSyntax'],
children: [
@@ -670,7 +670,7 @@ var definitions:ITypeDefinition[] = [
isTypeScriptSpecific: true
},
<any>{
name: 'MemberFunctionDeclarationSyntax',
name: 'MethodDeclarationSyntax',
baseType: 'ISyntaxNode',
interfaces: ['IMemberDeclarationSyntax', 'IPropertyAssignmentSyntax'],
children: [
@@ -708,7 +708,7 @@ var definitions:ITypeDefinition[] = [
isTypeScriptSpecific: true
},
<any>{
name: 'MemberVariableDeclarationSyntax',
name: 'PropertyDeclarationSyntax',
baseType: 'ISyntaxNode',
interfaces: ['IMemberDeclarationSyntax'],
children: [
@@ -880,7 +880,7 @@ var definitions:ITypeDefinition[] = [
]
},
<any>{
name: 'CastExpressionSyntax',
name: 'TypeAssertionExpressionSyntax',
baseType: 'ISyntaxNode',
interfaces: ['IUnaryExpressionSyntax'],
children: [
@@ -1029,7 +1029,7 @@ var definitions:ITypeDefinition[] = [
interfaces: ['IUnaryExpressionSyntax'],
children: [
<any>{ name: 'awaitKeyword', isToken: true },
<any>{ name: 'expression', type: 'IExpressionSyntax', isOptional: true }]
<any>{ name: 'expression', type: 'IUnaryExpressionSyntax', isOptional: true }]
},
<any>{
name: 'DebuggerStatementSyntax',
@@ -150,21 +150,21 @@ module TypeScript {
}
export interface ExportAssignmentConstructor { new (data: number, modifiers: ISyntaxToken[], exportKeyword: ISyntaxToken, equalsToken: ISyntaxToken, identifier: ISyntaxToken, semicolonToken: ISyntaxToken): ExportAssignmentSyntax }
export interface MemberFunctionDeclarationSyntax extends ISyntaxNode, IMemberDeclarationSyntax, IPropertyAssignmentSyntax {
export interface MethodDeclarationSyntax extends ISyntaxNode, IMemberDeclarationSyntax, IPropertyAssignmentSyntax {
modifiers: ISyntaxToken[];
asterixToken: ISyntaxToken;
propertyName: IPropertyNameSyntax;
callSignature: CallSignatureSyntax;
body: BlockSyntax | ExpressionBody | ISyntaxToken;
}
export interface MemberFunctionDeclarationConstructor { new (data: number, modifiers: ISyntaxToken[], asterixToken: ISyntaxToken, propertyName: IPropertyNameSyntax, callSignature: CallSignatureSyntax, body: BlockSyntax | ExpressionBody | ISyntaxToken): MemberFunctionDeclarationSyntax }
export interface MethodDeclarationConstructor { new (data: number, modifiers: ISyntaxToken[], asterixToken: ISyntaxToken, propertyName: IPropertyNameSyntax, callSignature: CallSignatureSyntax, body: BlockSyntax | ExpressionBody | ISyntaxToken): MethodDeclarationSyntax }
export interface MemberVariableDeclarationSyntax extends ISyntaxNode, IMemberDeclarationSyntax {
export interface PropertyDeclarationSyntax extends ISyntaxNode, IMemberDeclarationSyntax {
modifiers: ISyntaxToken[];
variableDeclarator: VariableDeclaratorSyntax;
semicolonToken: ISyntaxToken;
}
export interface MemberVariableDeclarationConstructor { new (data: number, modifiers: ISyntaxToken[], variableDeclarator: VariableDeclaratorSyntax, semicolonToken: ISyntaxToken): MemberVariableDeclarationSyntax }
export interface PropertyDeclarationConstructor { new (data: number, modifiers: ISyntaxToken[], variableDeclarator: VariableDeclaratorSyntax, semicolonToken: ISyntaxToken): PropertyDeclarationSyntax }
export interface ConstructorDeclarationSyntax extends ISyntaxNode, IClassElementSyntax {
modifiers: ISyntaxToken[];
@@ -426,12 +426,12 @@ module TypeScript {
}
export interface PostfixUnaryExpressionConstructor { new (data: number, operand: ILeftHandSideExpressionSyntax, operatorToken: ISyntaxToken): PostfixUnaryExpressionSyntax }
export interface MemberAccessExpressionSyntax extends ISyntaxNode, IMemberExpressionSyntax, ICallExpressionSyntax {
export interface PropertyAccessExpressionSyntax extends ISyntaxNode, IMemberExpressionSyntax, ICallExpressionSyntax {
expression: ILeftHandSideExpressionSyntax;
dotToken: ISyntaxToken;
name: ISyntaxToken;
}
export interface MemberAccessExpressionConstructor { new (data: number, expression: ILeftHandSideExpressionSyntax, dotToken: ISyntaxToken, name: ISyntaxToken): MemberAccessExpressionSyntax }
export interface PropertyAccessExpressionConstructor { new (data: number, expression: ILeftHandSideExpressionSyntax, dotToken: ISyntaxToken, name: ISyntaxToken): PropertyAccessExpressionSyntax }
export interface InvocationExpressionSyntax extends ISyntaxNode, ICallExpressionSyntax {
expression: ILeftHandSideExpressionSyntax;
@@ -483,13 +483,13 @@ module TypeScript {
}
export interface SimpleArrowFunctionExpressionConstructor { new (data: number, asyncKeyword: ISyntaxToken, parameter: ParameterSyntax, equalsGreaterThanToken: ISyntaxToken, body: BlockSyntax | IExpressionSyntax): SimpleArrowFunctionExpressionSyntax }
export interface CastExpressionSyntax extends ISyntaxNode, IUnaryExpressionSyntax {
export interface TypeAssertionExpressionSyntax extends ISyntaxNode, IUnaryExpressionSyntax {
lessThanToken: ISyntaxToken;
type: ITypeSyntax;
greaterThanToken: ISyntaxToken;
expression: IUnaryExpressionSyntax;
}
export interface CastExpressionConstructor { new (data: number, lessThanToken: ISyntaxToken, type: ITypeSyntax, greaterThanToken: ISyntaxToken, expression: IUnaryExpressionSyntax): CastExpressionSyntax }
export interface TypeAssertionExpressionConstructor { new (data: number, lessThanToken: ISyntaxToken, type: ITypeSyntax, greaterThanToken: ISyntaxToken, expression: IUnaryExpressionSyntax): TypeAssertionExpressionSyntax }
export interface ElementAccessExpressionSyntax extends ISyntaxNode, IMemberExpressionSyntax, ICallExpressionSyntax {
expression: ILeftHandSideExpressionSyntax;
@@ -534,9 +534,9 @@ module TypeScript {
export interface AwaitExpressionSyntax extends ISyntaxNode, IUnaryExpressionSyntax {
awaitKeyword: ISyntaxToken;
expression: IExpressionSyntax;
expression: IUnaryExpressionSyntax;
}
export interface AwaitExpressionConstructor { new (data: number, awaitKeyword: ISyntaxToken, expression: IExpressionSyntax): AwaitExpressionSyntax }
export interface AwaitExpressionConstructor { new (data: number, awaitKeyword: ISyntaxToken, expression: IUnaryExpressionSyntax): AwaitExpressionSyntax }
export interface VariableDeclarationSyntax extends ISyntaxNode {
varConstOrLetKeyword: ISyntaxToken;
+4 -4
View File
@@ -179,8 +179,8 @@ module TypeScript {
ExportAssignment,
// ClassElements
MemberFunctionDeclaration,
MemberVariableDeclaration,
MethodDeclaration,
PropertyDeclaration,
ConstructorDeclaration,
// ClassElement and PropertyAssignment
@@ -222,7 +222,7 @@ module TypeScript {
ConditionalExpression,
BinaryExpression,
PostfixUnaryExpression,
MemberAccessExpression,
PropertyAccessExpression,
InvocationExpression,
ArrayLiteralExpression,
ObjectLiteralExpression,
@@ -230,7 +230,7 @@ module TypeScript {
ParenthesizedExpression,
ParenthesizedArrowFunctionExpression,
SimpleArrowFunctionExpression,
CastExpression,
TypeAssertionExpression,
ElementAccessExpression,
FunctionExpression,
OmittedExpression,
@@ -409,7 +409,7 @@ module TypeScript {
}
}
export var MemberFunctionDeclarationSyntax: MemberFunctionDeclarationConstructor = <any>function(data: number, modifiers: ISyntaxToken[], asterixToken: ISyntaxToken, propertyName: IPropertyNameSyntax, callSignature: CallSignatureSyntax, body: BlockSyntax | ExpressionBody | ISyntaxToken) {
export var MethodDeclarationSyntax: MethodDeclarationConstructor = <any>function(data: number, modifiers: ISyntaxToken[], asterixToken: ISyntaxToken, propertyName: IPropertyNameSyntax, callSignature: CallSignatureSyntax, body: BlockSyntax | ExpressionBody | ISyntaxToken) {
if (data) { this.__data = data; }
this.modifiers = modifiers,
this.asterixToken = asterixToken,
@@ -422,9 +422,9 @@ module TypeScript {
callSignature.parent = this,
body && (body.parent = this);
};
MemberFunctionDeclarationSyntax.prototype.kind = SyntaxKind.MemberFunctionDeclaration;
MemberFunctionDeclarationSyntax.prototype.childCount = 5;
MemberFunctionDeclarationSyntax.prototype.childAt = function(index: number): ISyntaxElement {
MethodDeclarationSyntax.prototype.kind = SyntaxKind.MethodDeclaration;
MethodDeclarationSyntax.prototype.childCount = 5;
MethodDeclarationSyntax.prototype.childAt = function(index: number): ISyntaxElement {
switch (index) {
case 0: return this.modifiers;
case 1: return this.asterixToken;
@@ -434,7 +434,7 @@ module TypeScript {
}
}
export var MemberVariableDeclarationSyntax: MemberVariableDeclarationConstructor = <any>function(data: number, modifiers: ISyntaxToken[], variableDeclarator: VariableDeclaratorSyntax, semicolonToken: ISyntaxToken) {
export var PropertyDeclarationSyntax: PropertyDeclarationConstructor = <any>function(data: number, modifiers: ISyntaxToken[], variableDeclarator: VariableDeclaratorSyntax, semicolonToken: ISyntaxToken) {
if (data) { this.__data = data; }
this.modifiers = modifiers,
this.variableDeclarator = variableDeclarator,
@@ -443,9 +443,9 @@ module TypeScript {
variableDeclarator.parent = this,
semicolonToken && (semicolonToken.parent = this);
};
MemberVariableDeclarationSyntax.prototype.kind = SyntaxKind.MemberVariableDeclaration;
MemberVariableDeclarationSyntax.prototype.childCount = 3;
MemberVariableDeclarationSyntax.prototype.childAt = function(index: number): ISyntaxElement {
PropertyDeclarationSyntax.prototype.kind = SyntaxKind.PropertyDeclaration;
PropertyDeclarationSyntax.prototype.childCount = 3;
PropertyDeclarationSyntax.prototype.childAt = function(index: number): ISyntaxElement {
switch (index) {
case 0: return this.modifiers;
case 1: return this.variableDeclarator;
@@ -1167,7 +1167,7 @@ module TypeScript {
}
}
export var MemberAccessExpressionSyntax: MemberAccessExpressionConstructor = <any>function(data: number, expression: ILeftHandSideExpressionSyntax, dotToken: ISyntaxToken, name: ISyntaxToken) {
export var PropertyAccessExpressionSyntax: PropertyAccessExpressionConstructor = <any>function(data: number, expression: ILeftHandSideExpressionSyntax, dotToken: ISyntaxToken, name: ISyntaxToken) {
if (data) { this.__data = data; }
this.expression = expression,
this.dotToken = dotToken,
@@ -1176,9 +1176,9 @@ module TypeScript {
dotToken.parent = this,
name.parent = this;
};
MemberAccessExpressionSyntax.prototype.kind = SyntaxKind.MemberAccessExpression;
MemberAccessExpressionSyntax.prototype.childCount = 3;
MemberAccessExpressionSyntax.prototype.childAt = function(index: number): ISyntaxElement {
PropertyAccessExpressionSyntax.prototype.kind = SyntaxKind.PropertyAccessExpression;
PropertyAccessExpressionSyntax.prototype.childCount = 3;
PropertyAccessExpressionSyntax.prototype.childAt = function(index: number): ISyntaxElement {
switch (index) {
case 0: return this.expression;
case 1: return this.dotToken;
@@ -1322,7 +1322,7 @@ module TypeScript {
}
}
export var CastExpressionSyntax: CastExpressionConstructor = <any>function(data: number, lessThanToken: ISyntaxToken, type: ITypeSyntax, greaterThanToken: ISyntaxToken, expression: IUnaryExpressionSyntax) {
export var TypeAssertionExpressionSyntax: TypeAssertionExpressionConstructor = <any>function(data: number, lessThanToken: ISyntaxToken, type: ITypeSyntax, greaterThanToken: ISyntaxToken, expression: IUnaryExpressionSyntax) {
if (data) { this.__data = data; }
this.lessThanToken = lessThanToken,
this.type = type,
@@ -1333,9 +1333,9 @@ module TypeScript {
greaterThanToken.parent = this,
expression.parent = this;
};
CastExpressionSyntax.prototype.kind = SyntaxKind.CastExpression;
CastExpressionSyntax.prototype.childCount = 4;
CastExpressionSyntax.prototype.childAt = function(index: number): ISyntaxElement {
TypeAssertionExpressionSyntax.prototype.kind = SyntaxKind.TypeAssertionExpression;
TypeAssertionExpressionSyntax.prototype.childCount = 4;
TypeAssertionExpressionSyntax.prototype.childAt = function(index: number): ISyntaxElement {
switch (index) {
case 0: return this.lessThanToken;
case 1: return this.type;
@@ -1454,7 +1454,7 @@ module TypeScript {
}
}
export var AwaitExpressionSyntax: AwaitExpressionConstructor = <any>function(data: number, awaitKeyword: ISyntaxToken, expression: IExpressionSyntax) {
export var AwaitExpressionSyntax: AwaitExpressionConstructor = <any>function(data: number, awaitKeyword: ISyntaxToken, expression: IUnaryExpressionSyntax) {
if (data) { this.__data = data; }
this.awaitKeyword = awaitKeyword,
this.expression = expression,
+5 -5
View File
@@ -551,13 +551,13 @@ module TypeScript {
return false;
}
public visitMemberVariableDeclaration(node: MemberVariableDeclarationSyntax): void {
public visitPropertyDeclaration(node: PropertyDeclarationSyntax): void {
if (this.checkClassElementModifiers(node.modifiers) ||
this.checkForDisallowedAsyncModifier(node.modifiers)) {
return;
}
super.visitMemberVariableDeclaration(node);
super.visitPropertyDeclaration(node);
}
public visitMethodSignature(node: MethodSignatureSyntax): void {
@@ -579,7 +579,7 @@ module TypeScript {
super.visitPropertySignature(node);
}
public visitMemberFunctionDeclaration(node: MemberFunctionDeclarationSyntax): void {
public visitMethodDeclaration(node: MethodDeclarationSyntax): void {
if (node.parent && node.parent.parent &&
node.parent.kind === SyntaxKind.List && node.parent.parent.kind === SyntaxKind.ObjectLiteralExpression) {
@@ -603,7 +603,7 @@ module TypeScript {
return;
}
super.visitMemberFunctionDeclaration(node);
super.visitMethodDeclaration(node);
}
private checkForDisallowedObjectLiteralMethod(modifiers: ISyntaxToken[]): boolean {
@@ -1556,7 +1556,7 @@ module TypeScript {
}
private checkVariableDeclaratorIdentifier(node: VariableDeclaratorSyntax): boolean {
if (node.parent.kind !== SyntaxKind.MemberVariableDeclaration) {
if (node.parent.kind !== SyntaxKind.PropertyDeclaration) {
Debug.assert(isToken(node.propertyName), "A normal variable declarator must always have a token for a name.");
if (this.checkForDisallowedEvalOrArguments(node, <ISyntaxToken>node.propertyName)) {
return true;
+5 -41
View File
@@ -18,7 +18,7 @@ module TypeScript {
case SyntaxKind.ParenthesizedArrowFunctionExpression:
case SyntaxKind.FunctionExpression:
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.MemberFunctionDeclaration:
case SyntaxKind.MethodDeclaration:
case SyntaxKind.ConstructorDeclaration:
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
@@ -44,7 +44,7 @@ module TypeScript {
export function isLeftHandSizeExpression(element: ISyntaxElement) {
if (element) {
switch (element.kind) {
case SyntaxKind.MemberAccessExpression:
case SyntaxKind.PropertyAccessExpression:
case SyntaxKind.ElementAccessExpression:
case SyntaxKind.TemplateAccessExpression:
case SyntaxKind.ObjectCreationExpression:
@@ -101,11 +101,10 @@ module TypeScript {
switch (element.kind) {
case SyntaxKind.ConstructorDeclaration:
case SyntaxKind.IndexSignature:
case SyntaxKind.MemberFunctionDeclaration:
case SyntaxKind.MethodDeclaration:
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
case SyntaxKind.MemberFunctionDeclaration:
case SyntaxKind.MemberVariableDeclaration:
case SyntaxKind.PropertyDeclaration:
return true;
}
}
@@ -186,7 +185,7 @@ module TypeScript {
switch (parent.kind) {
case SyntaxKind.TypeArgumentList:
case SyntaxKind.TypeParameterList:
case SyntaxKind.CastExpression:
case SyntaxKind.TypeAssertionExpression:
return true;
}
}
@@ -227,40 +226,5 @@ module TypeScript {
return undefined;
}
}
export function isAmbientDeclarationSyntax(positionNode: ISyntaxNode): boolean {
if (!positionNode) {
return false;
}
var node = positionNode;
switch (node.kind) {
case SyntaxKind.ModuleDeclaration:
case SyntaxKind.ClassDeclaration:
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.VariableStatement:
case SyntaxKind.EnumDeclaration:
if (SyntaxUtilities.containsToken(<ISyntaxToken[]>(<any>node).modifiers, SyntaxKind.DeclareKeyword)) {
return true;
}
// Fall through to check if syntax container is ambient
case SyntaxKind.ImportDeclaration:
case SyntaxKind.ConstructorDeclaration:
case SyntaxKind.MemberFunctionDeclaration:
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
case SyntaxKind.MemberVariableDeclaration:
if (SyntaxUtilities.isClassElement(node) || SyntaxUtilities.isModuleElement(node)) {
return SyntaxUtilities.isAmbientDeclarationSyntax(Syntax.containingNode(positionNode));
}
case SyntaxKind.EnumElement:
return SyntaxUtilities.isAmbientDeclarationSyntax(Syntax.containingNode(Syntax.containingNode(positionNode)));
default:
return SyntaxUtilities.isAmbientDeclarationSyntax(Syntax.containingNode(positionNode));
}
}
}
}
@@ -22,8 +22,8 @@ module TypeScript {
case SyntaxKind.EnumDeclaration: return visitor.visitEnumDeclaration(<EnumDeclarationSyntax>element);
case SyntaxKind.ImportDeclaration: return visitor.visitImportDeclaration(<ImportDeclarationSyntax>element);
case SyntaxKind.ExportAssignment: return visitor.visitExportAssignment(<ExportAssignmentSyntax>element);
case SyntaxKind.MemberFunctionDeclaration: return visitor.visitMemberFunctionDeclaration(<MemberFunctionDeclarationSyntax>element);
case SyntaxKind.MemberVariableDeclaration: return visitor.visitMemberVariableDeclaration(<MemberVariableDeclarationSyntax>element);
case SyntaxKind.MethodDeclaration: return visitor.visitMethodDeclaration(<MethodDeclarationSyntax>element);
case SyntaxKind.PropertyDeclaration: return visitor.visitPropertyDeclaration(<PropertyDeclarationSyntax>element);
case SyntaxKind.ConstructorDeclaration: return visitor.visitConstructorDeclaration(<ConstructorDeclarationSyntax>element);
case SyntaxKind.GetAccessor: return visitor.visitGetAccessor(<GetAccessorSyntax>element);
case SyntaxKind.SetAccessor: return visitor.visitSetAccessor(<SetAccessorSyntax>element);
@@ -57,7 +57,7 @@ module TypeScript {
case SyntaxKind.ConditionalExpression: return visitor.visitConditionalExpression(<ConditionalExpressionSyntax>element);
case SyntaxKind.BinaryExpression: return visitor.visitBinaryExpression(<BinaryExpressionSyntax>element);
case SyntaxKind.PostfixUnaryExpression: return visitor.visitPostfixUnaryExpression(<PostfixUnaryExpressionSyntax>element);
case SyntaxKind.MemberAccessExpression: return visitor.visitMemberAccessExpression(<MemberAccessExpressionSyntax>element);
case SyntaxKind.PropertyAccessExpression: return visitor.visitPropertyAccessExpression(<PropertyAccessExpressionSyntax>element);
case SyntaxKind.InvocationExpression: return visitor.visitInvocationExpression(<InvocationExpressionSyntax>element);
case SyntaxKind.ArrayLiteralExpression: return visitor.visitArrayLiteralExpression(<ArrayLiteralExpressionSyntax>element);
case SyntaxKind.ObjectLiteralExpression: return visitor.visitObjectLiteralExpression(<ObjectLiteralExpressionSyntax>element);
@@ -65,7 +65,7 @@ module TypeScript {
case SyntaxKind.ParenthesizedExpression: return visitor.visitParenthesizedExpression(<ParenthesizedExpressionSyntax>element);
case SyntaxKind.ParenthesizedArrowFunctionExpression: return visitor.visitParenthesizedArrowFunctionExpression(<ParenthesizedArrowFunctionExpressionSyntax>element);
case SyntaxKind.SimpleArrowFunctionExpression: return visitor.visitSimpleArrowFunctionExpression(<SimpleArrowFunctionExpressionSyntax>element);
case SyntaxKind.CastExpression: return visitor.visitCastExpression(<CastExpressionSyntax>element);
case SyntaxKind.TypeAssertionExpression: return visitor.visitTypeAssertionExpression(<TypeAssertionExpressionSyntax>element);
case SyntaxKind.ElementAccessExpression: return visitor.visitElementAccessExpression(<ElementAccessExpressionSyntax>element);
case SyntaxKind.FunctionExpression: return visitor.visitFunctionExpression(<FunctionExpressionSyntax>element);
case SyntaxKind.OmittedExpression: return visitor.visitOmittedExpression(<OmittedExpressionSyntax>element);
@@ -122,8 +122,8 @@ module TypeScript {
visitEnumDeclaration(node: EnumDeclarationSyntax): any;
visitImportDeclaration(node: ImportDeclarationSyntax): any;
visitExportAssignment(node: ExportAssignmentSyntax): any;
visitMemberFunctionDeclaration(node: MemberFunctionDeclarationSyntax): any;
visitMemberVariableDeclaration(node: MemberVariableDeclarationSyntax): any;
visitMethodDeclaration(node: MethodDeclarationSyntax): any;
visitPropertyDeclaration(node: PropertyDeclarationSyntax): any;
visitConstructorDeclaration(node: ConstructorDeclarationSyntax): any;
visitGetAccessor(node: GetAccessorSyntax): any;
visitSetAccessor(node: SetAccessorSyntax): any;
@@ -157,7 +157,7 @@ module TypeScript {
visitConditionalExpression(node: ConditionalExpressionSyntax): any;
visitBinaryExpression(node: BinaryExpressionSyntax): any;
visitPostfixUnaryExpression(node: PostfixUnaryExpressionSyntax): any;
visitMemberAccessExpression(node: MemberAccessExpressionSyntax): any;
visitPropertyAccessExpression(node: PropertyAccessExpressionSyntax): any;
visitInvocationExpression(node: InvocationExpressionSyntax): any;
visitArrayLiteralExpression(node: ArrayLiteralExpressionSyntax): any;
visitObjectLiteralExpression(node: ObjectLiteralExpressionSyntax): any;
@@ -165,7 +165,7 @@ module TypeScript {
visitParenthesizedExpression(node: ParenthesizedExpressionSyntax): any;
visitParenthesizedArrowFunctionExpression(node: ParenthesizedArrowFunctionExpressionSyntax): any;
visitSimpleArrowFunctionExpression(node: SimpleArrowFunctionExpressionSyntax): any;
visitCastExpression(node: CastExpressionSyntax): any;
visitTypeAssertionExpression(node: TypeAssertionExpressionSyntax): any;
visitElementAccessExpression(node: ElementAccessExpressionSyntax): any;
visitFunctionExpression(node: FunctionExpressionSyntax): any;
visitOmittedExpression(node: OmittedExpressionSyntax): any;
@@ -149,7 +149,7 @@ module TypeScript {
this.visitOptionalToken(node.semicolonToken);
}
public visitMemberFunctionDeclaration(node: MemberFunctionDeclarationSyntax): void {
public visitMethodDeclaration(node: MethodDeclarationSyntax): void {
this.visitList(node.modifiers);
this.visitOptionalToken(node.asterixToken);
visitNodeOrToken(this, node.propertyName);
@@ -157,7 +157,7 @@ module TypeScript {
visitNodeOrToken(this, node.body);
}
public visitMemberVariableDeclaration(node: MemberVariableDeclarationSyntax): void {
public visitPropertyDeclaration(node: PropertyDeclarationSyntax): void {
this.visitList(node.modifiers);
visitNodeOrToken(this, node.variableDeclarator);
this.visitOptionalToken(node.semicolonToken);
@@ -390,7 +390,7 @@ module TypeScript {
this.visitToken(node.operatorToken);
}
public visitMemberAccessExpression(node: MemberAccessExpressionSyntax): void {
public visitPropertyAccessExpression(node: PropertyAccessExpressionSyntax): void {
visitNodeOrToken(this, node.expression);
this.visitToken(node.dotToken);
this.visitToken(node.name);
@@ -439,7 +439,7 @@ module TypeScript {
visitNodeOrToken(this, node.body);
}
public visitCastExpression(node: CastExpressionSyntax): void {
public visitTypeAssertionExpression(node: TypeAssertionExpressionSyntax): void {
this.visitToken(node.lessThanToken);
visitNodeOrToken(this, node.type);
this.visitToken(node.greaterThanToken);