mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Add support for parsing generator declarations.
Conflicts: src/services/syntax/SyntaxGenerator.js.map
This commit is contained in:
@@ -910,9 +910,9 @@ var definitions = [
|
||||
baseType: 'ISyntaxNode',
|
||||
interfaces: ['IModuleReferenceSyntax'],
|
||||
children: [
|
||||
{ name: 'requireKeyword', isToken: true, tokenKinds: ['RequireKeyword'], excludeFromAST: true },
|
||||
{ name: 'requireKeyword', isToken: true, excludeFromAST: true },
|
||||
{ name: 'openParenToken', isToken: true, excludeFromAST: true },
|
||||
{ name: 'stringLiteral', isToken: true, tokenKinds: ['StringLiteral'] },
|
||||
{ name: 'stringLiteral', isToken: true },
|
||||
{ name: 'closeParenToken', isToken: true, excludeFromAST: true }
|
||||
],
|
||||
isTypeScriptSpecific: true
|
||||
@@ -933,7 +933,7 @@ var definitions = [
|
||||
children: [
|
||||
{ name: 'modifiers', isList: true, elementType: 'ISyntaxToken' },
|
||||
{ name: 'importKeyword', isToken: true, excludeFromAST: true },
|
||||
{ name: 'identifier', isToken: true, tokenKinds: ['IdentifierName'] },
|
||||
{ name: 'identifier', isToken: true },
|
||||
{ name: 'equalsToken', isToken: true, excludeFromAST: true },
|
||||
{ name: 'moduleReference', type: 'IModuleReferenceSyntax' },
|
||||
{ name: 'semicolonToken', isToken: true, isOptional: true, excludeFromAST: true }
|
||||
@@ -947,7 +947,7 @@ var definitions = [
|
||||
children: [
|
||||
{ name: 'exportKeyword', isToken: true, excludeFromAST: true },
|
||||
{ name: 'equalsToken', isToken: true, excludeFromAST: true },
|
||||
{ name: 'identifier', isToken: true, tokenKinds: ['IdentifierName'] },
|
||||
{ name: 'identifier', isToken: true },
|
||||
{ name: 'semicolonToken', isToken: true, isOptional: true, excludeFromAST: true }
|
||||
],
|
||||
isTypeScriptSpecific: true
|
||||
@@ -959,7 +959,7 @@ var definitions = [
|
||||
children: [
|
||||
{ name: 'modifiers', isList: true, elementType: 'ISyntaxToken' },
|
||||
{ name: 'classKeyword', isToken: true, excludeFromAST: true },
|
||||
{ name: 'identifier', isToken: true, tokenKinds: ['IdentifierName'] },
|
||||
{ name: 'identifier', isToken: true },
|
||||
{ name: 'typeParameterList', type: 'TypeParameterListSyntax', isOptional: true },
|
||||
{ name: 'heritageClauses', isList: true, elementType: 'HeritageClauseSyntax' },
|
||||
{ name: 'openBraceToken', isToken: true, excludeFromAST: true },
|
||||
@@ -975,7 +975,7 @@ var definitions = [
|
||||
children: [
|
||||
{ name: 'modifiers', isList: true, elementType: 'ISyntaxToken' },
|
||||
{ name: 'interfaceKeyword', isToken: true, excludeFromAST: true },
|
||||
{ name: 'identifier', isToken: true, tokenKinds: ['IdentifierName'] },
|
||||
{ name: 'identifier', isToken: true },
|
||||
{ name: 'typeParameterList', type: 'TypeParameterListSyntax', isOptional: true },
|
||||
{ name: 'heritageClauses', isList: true, elementType: 'HeritageClauseSyntax' },
|
||||
{ name: 'body', type: 'ObjectTypeSyntax' }
|
||||
@@ -1012,7 +1012,8 @@ var definitions = [
|
||||
children: [
|
||||
{ name: 'modifiers', isList: true, elementType: 'ISyntaxToken', isTypeScriptSpecific: true },
|
||||
{ name: 'functionKeyword', isToken: true, excludeFromAST: true },
|
||||
{ name: 'identifier', isToken: true, tokenKinds: ['IdentifierName'] },
|
||||
{ name: 'asterixToken', isToken: true, isOptional: true },
|
||||
{ name: 'identifier', isToken: true },
|
||||
{ name: 'callSignature', type: 'CallSignatureSyntax' },
|
||||
{ name: 'body', type: 'BlockSyntax | ISyntaxToken', isOptional: true }
|
||||
]
|
||||
@@ -1116,7 +1117,7 @@ var definitions = [
|
||||
children: [
|
||||
{ name: 'left', type: 'INameSyntax' },
|
||||
{ name: 'dotToken', isToken: true, excludeFromAST: true },
|
||||
{ name: 'right', isToken: true, tokenKinds: ['IdentifierName'] }
|
||||
{ name: 'right', isToken: true }
|
||||
],
|
||||
isTypeScriptSpecific: true
|
||||
},
|
||||
@@ -1255,7 +1256,7 @@ var definitions = [
|
||||
children: [
|
||||
{ name: 'dotDotDotToken', isToken: true, isOptional: true, isTypeScriptSpecific: true },
|
||||
{ name: 'modifiers', isList: true, elementType: 'ISyntaxToken' },
|
||||
{ name: 'identifier', isToken: true, tokenKinds: ['IdentifierName'] },
|
||||
{ name: 'identifier', isToken: true },
|
||||
{ name: 'questionToken', isToken: true, isOptional: true, isTypeScriptSpecific: true },
|
||||
{ name: 'typeAnnotation', type: 'TypeAnnotationSyntax', isOptional: true, isTypeScriptSpecific: true },
|
||||
{ name: 'equalsValueClause', type: 'EqualsValueClauseSyntax', isOptional: true, isTypeScriptSpecific: true }
|
||||
@@ -1268,7 +1269,7 @@ var definitions = [
|
||||
children: [
|
||||
{ name: 'expression', type: 'ILeftHandSideExpressionSyntax' },
|
||||
{ name: 'dotToken', isToken: true, excludeFromAST: true },
|
||||
{ name: 'name', isToken: true, tokenKinds: ['IdentifierName'] }
|
||||
{ name: 'name', isToken: true }
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -1434,7 +1435,7 @@ var definitions = [
|
||||
name: 'TypeParameterSyntax',
|
||||
baseType: 'ISyntaxNode',
|
||||
children: [
|
||||
{ name: 'identifier', isToken: true, tokenKinds: ['IdentifierName'] },
|
||||
{ name: 'identifier', isToken: true },
|
||||
{ name: 'constraint', type: 'ConstraintSyntax', isOptional: true }
|
||||
],
|
||||
isTypeScriptSpecific: true
|
||||
@@ -1496,6 +1497,7 @@ var definitions = [
|
||||
interfaces: ['IMemberDeclarationSyntax'],
|
||||
children: [
|
||||
{ name: 'modifiers', isList: true, elementType: 'ISyntaxToken' },
|
||||
{ name: 'asterixToken', isToken: true, isOptional: true },
|
||||
{ name: 'propertyName', type: 'IPropertyNameSyntax' },
|
||||
{ name: 'callSignature', type: 'CallSignatureSyntax' },
|
||||
{ name: 'body', type: 'BlockSyntax | ISyntaxToken', isOptional: true }
|
||||
@@ -1620,7 +1622,7 @@ var definitions = [
|
||||
interfaces: ['IStatementSyntax'],
|
||||
children: [
|
||||
{ name: 'breakKeyword', isToken: true },
|
||||
{ name: 'identifier', isToken: true, isOptional: true, tokenKinds: ['IdentifierName'] },
|
||||
{ name: 'identifier', isToken: true, isOptional: true },
|
||||
{ name: 'semicolonToken', isToken: true, isOptional: true, excludeFromAST: true }
|
||||
]
|
||||
},
|
||||
@@ -1630,7 +1632,7 @@ var definitions = [
|
||||
interfaces: ['IStatementSyntax'],
|
||||
children: [
|
||||
{ name: 'continueKeyword', isToken: true },
|
||||
{ name: 'identifier', isToken: true, isOptional: true, tokenKinds: ['IdentifierName'] },
|
||||
{ name: 'identifier', isToken: true, isOptional: true },
|
||||
{ name: 'semicolonToken', isToken: true, isOptional: true, excludeFromAST: true }
|
||||
]
|
||||
},
|
||||
@@ -1642,9 +1644,9 @@ var definitions = [
|
||||
{ name: 'forKeyword', isToken: true, excludeFromAST: true },
|
||||
{ name: 'openParenToken', isToken: true, excludeFromAST: true },
|
||||
{ name: 'initializer', type: 'VariableDeclarationSyntax | IExpressionSyntax', isOptional: true },
|
||||
{ name: 'firstSemicolonToken', isToken: true, tokenKinds: ['SemicolonToken'], excludeFromAST: true },
|
||||
{ name: 'firstSemicolonToken', isToken: true, excludeFromAST: true },
|
||||
{ name: 'condition', type: 'IExpressionSyntax', isOptional: true },
|
||||
{ name: 'secondSemicolonToken', isToken: true, tokenKinds: ['SemicolonToken'], excludeFromAST: true },
|
||||
{ name: 'secondSemicolonToken', isToken: true, excludeFromAST: true },
|
||||
{ name: 'incrementor', type: 'IExpressionSyntax', isOptional: true },
|
||||
{ name: 'closeParenToken', isToken: true, excludeFromAST: true },
|
||||
{ name: 'statement', type: 'IStatementSyntax' }
|
||||
@@ -1695,7 +1697,7 @@ var definitions = [
|
||||
children: [
|
||||
{ name: 'modifiers', isList: true, elementType: 'ISyntaxToken' },
|
||||
{ name: 'enumKeyword', isToken: true, excludeFromAST: true },
|
||||
{ name: 'identifier', isToken: true, tokenKinds: ['IdentifierName'] },
|
||||
{ name: 'identifier', isToken: true },
|
||||
{ name: 'openBraceToken', isToken: true, excludeFromAST: true },
|
||||
{ name: 'enumElements', isSeparatedList: true, elementType: 'EnumElementSyntax' },
|
||||
{ name: 'closeBraceToken', isToken: true, excludeFromAST: true }
|
||||
@@ -1768,7 +1770,8 @@ var definitions = [
|
||||
interfaces: ['IPrimaryExpressionSyntax'],
|
||||
children: [
|
||||
{ name: 'functionKeyword', isToken: true, excludeFromAST: true },
|
||||
{ name: 'identifier', isToken: true, isOptional: true, tokenKinds: ['IdentifierName'] },
|
||||
{ name: 'asterixToken', isToken: true, isOptional: true },
|
||||
{ name: 'identifier', isToken: true, isOptional: true },
|
||||
{ name: 'callSignature', type: 'CallSignatureSyntax' },
|
||||
{ name: 'block', type: 'BlockSyntax' }
|
||||
]
|
||||
@@ -1798,7 +1801,7 @@ var definitions = [
|
||||
children: [
|
||||
{ name: 'catchKeyword', isToken: true, excludeFromAST: true },
|
||||
{ name: 'openParenToken', isToken: true, excludeFromAST: true },
|
||||
{ name: 'identifier', isToken: true, tokenKinds: ['IdentifierName'] },
|
||||
{ name: 'identifier', isToken: true },
|
||||
{ name: 'typeAnnotation', type: 'TypeAnnotationSyntax', isOptional: true, isTypeScriptSpecified: true },
|
||||
{ name: 'closeParenToken', isToken: true, excludeFromAST: true },
|
||||
{ name: 'block', type: 'BlockSyntax' }
|
||||
@@ -1817,7 +1820,7 @@ var definitions = [
|
||||
baseType: 'ISyntaxNode',
|
||||
interfaces: ['IStatementSyntax'],
|
||||
children: [
|
||||
{ name: 'identifier', isToken: true, tokenKinds: ['IdentifierName'] },
|
||||
{ name: 'identifier', isToken: true },
|
||||
{ name: 'colonToken', isToken: true, excludeFromAST: true },
|
||||
{ name: 'statement', type: 'IStatementSyntax' }
|
||||
]
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -163,6 +163,7 @@ module TypeScript.Parser {
|
||||
// all nodes would need extra state on them to store this info.
|
||||
var strictMode: boolean = false;
|
||||
var disallowIn: boolean = false;
|
||||
var allowYield: boolean = false;
|
||||
|
||||
// Current state of the parser. If we need to rewind we will store and reset these values as
|
||||
// appropriate.
|
||||
@@ -957,8 +958,9 @@ module TypeScript.Parser {
|
||||
if (isModifierKind(token.kind)) {
|
||||
// These are modifiers only if we see an actual keyword, identifier, string literal
|
||||
// or number following.
|
||||
// Note: we also allow [ for error conditions.
|
||||
// [ is for: static [a: number]
|
||||
//
|
||||
// [ is for: static [a: number] ...
|
||||
// [ is for: static [computedProp()] ...
|
||||
var nextToken = peekToken(index + 1);
|
||||
var nextTokenKind = nextToken.kind;
|
||||
|
||||
@@ -967,6 +969,8 @@ module TypeScript.Parser {
|
||||
case SyntaxKind.OpenBracketToken:
|
||||
case SyntaxKind.NumericLiteral:
|
||||
case SyntaxKind.StringLiteral:
|
||||
case SyntaxKind.NoSubstitutionTemplateToken:
|
||||
case SyntaxKind.AsteriskToken:
|
||||
return true;
|
||||
default:
|
||||
return SyntaxFacts.isAnyKeyword(nextTokenKind);
|
||||
@@ -1079,12 +1083,29 @@ module TypeScript.Parser {
|
||||
}
|
||||
|
||||
function isMemberVariableOrFunctionDeclaration(peekIndex: number, inErrorRecovery: boolean) {
|
||||
var tokenN = peekToken(peekIndex);
|
||||
var tokenNKind = tokenN.kind;
|
||||
|
||||
// If we have a '*', then this is a generator function.
|
||||
if (tokenNKind === SyntaxKind.AsteriskToken) {
|
||||
if (inErrorRecovery) {
|
||||
// If we're in error recovery, we might see a random * that is part of some
|
||||
// expression. Really, in order to view this as a generator function, we want
|
||||
// to see at least '*id<' or '*id('. Otherwise, we won't think of this as the
|
||||
// start of a member variable/function.
|
||||
return peekToken(peekIndex + 1).kind === SyntaxKind.IdentifierName &&
|
||||
(peekToken(peekIndex + 2).kind === SyntaxKind.LessThanToken || peekToken(peekIndex + 2).kind === SyntaxKind.OpenParenToken);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check if its the start of a property or method. Both must start with a property name.
|
||||
if (!isPropertyName(peekIndex, inErrorRecovery)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!SyntaxFacts.isAnyKeyword(peekToken(peekIndex).kind)) {
|
||||
if (!SyntaxFacts.isAnyKeyword(tokenNKind)) {
|
||||
// It wasn't a keyword. So this is definitely a member variable or function.
|
||||
return true;
|
||||
}
|
||||
@@ -1138,10 +1159,15 @@ module TypeScript.Parser {
|
||||
}
|
||||
else if (isMemberVariableOrFunctionDeclaration(/*peekIndex:*/ _modifierCount, inErrorRecovery)) {
|
||||
var modifiers = parseModifiers();
|
||||
var asterixToken = tryEatToken(SyntaxKind.AsteriskToken);
|
||||
var propertyName = parsePropertyName();
|
||||
|
||||
if (isCallSignature(/*peekIndex:*/ 0)) {
|
||||
return parseMemberFunctionDeclaration(modifiers, propertyName);
|
||||
// If we got a '*', then this is definitely a method. If we didn't get a '*', then
|
||||
// we must have gotten a property name. And if that's all we have, we have to check
|
||||
// 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);
|
||||
}
|
||||
else {
|
||||
return parseMemberVariableDeclaration(modifiers, propertyName);
|
||||
@@ -1171,12 +1197,13 @@ module TypeScript.Parser {
|
||||
isBlockOrArrow() ? parseFunctionBlock() : eatExplicitOrAutomaticSemicolon(/*allowWithoutNewline:*/ false));
|
||||
}
|
||||
|
||||
function parseMemberFunctionDeclaration(modifiers: ISyntaxToken[], propertyName: IPropertyNameSyntax): MemberFunctionDeclarationSyntax {
|
||||
function parseMemberFunctionDeclaration(modifiers: ISyntaxToken[], asterixToken: ISyntaxToken, propertyName: IPropertyNameSyntax): MemberFunctionDeclarationSyntax {
|
||||
// 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.
|
||||
return new MemberFunctionDeclarationSyntax(parseNodeData,
|
||||
modifiers,
|
||||
asterixToken,
|
||||
propertyName,
|
||||
parseCallSignature(/*requireCompleteTypeParameterList:*/ false),
|
||||
isBlockOrArrow() ? parseFunctionBlock() : eatExplicitOrAutomaticSemicolon(/*allowWithoutNewline:*/ false));
|
||||
@@ -1211,6 +1238,7 @@ module TypeScript.Parser {
|
||||
return new FunctionDeclarationSyntax(parseNodeData,
|
||||
parseModifiers(),
|
||||
eatToken(SyntaxKind.FunctionKeyword),
|
||||
tryEatToken(SyntaxKind.AsteriskToken),
|
||||
eatIdentifierToken(),
|
||||
parseCallSignature(/*requireCompleteTypeParameterList:*/ false),
|
||||
isBlockOrArrow() ? parseFunctionBlock() : eatExplicitOrAutomaticSemicolon(/*allowWithoutNewline:*/ false));
|
||||
@@ -2797,7 +2825,9 @@ module TypeScript.Parser {
|
||||
|
||||
function parseFunctionExpression(functionKeyword: ISyntaxToken): FunctionExpressionSyntax {
|
||||
return new FunctionExpressionSyntax(parseNodeData,
|
||||
consumeToken(functionKeyword), eatOptionalIdentifierToken(),
|
||||
consumeToken(functionKeyword),
|
||||
tryEatToken(SyntaxKind.AsteriskToken),
|
||||
eatOptionalIdentifierToken(),
|
||||
parseCallSignature(/*requireCompleteTypeParameterList:*/ false),
|
||||
parseFunctionBlock());
|
||||
}
|
||||
@@ -3271,10 +3301,13 @@ module TypeScript.Parser {
|
||||
// If it was a keyword, convert it to an identifier name.
|
||||
return eatIdentifierNameToken();
|
||||
}
|
||||
else {
|
||||
else if (isLiteralPropertyName(_currentToken)) {
|
||||
// Must have been a literal.
|
||||
return consumeToken(_currentToken);
|
||||
}
|
||||
else {
|
||||
return eatIdentifierToken();
|
||||
}
|
||||
}
|
||||
|
||||
function parseComputedPropertyName(openBracketToken: ISyntaxToken): ComputedPropertyNameSyntax {
|
||||
|
||||
@@ -23,7 +23,6 @@ interface IMemberDefinition {
|
||||
isSeparatedList?: boolean;
|
||||
requiresAtLeastOneItem?: boolean;
|
||||
isOptional?: boolean;
|
||||
tokenKinds?: string[];
|
||||
isTypeScriptSpecific: boolean;
|
||||
elementType?: string;
|
||||
}
|
||||
@@ -56,9 +55,9 @@ var definitions:ITypeDefinition[] = [
|
||||
baseType: 'ISyntaxNode',
|
||||
interfaces: ['IModuleReferenceSyntax'],
|
||||
children: [
|
||||
<any>{ name: 'requireKeyword', isToken: true, tokenKinds: ['RequireKeyword'], excludeFromAST: true },
|
||||
<any>{ name: 'requireKeyword', isToken: true, excludeFromAST: true },
|
||||
<any>{ name: 'openParenToken', isToken: true, excludeFromAST: true },
|
||||
<any>{ name: 'stringLiteral', isToken: true, tokenKinds: ['StringLiteral'] },
|
||||
<any>{ name: 'stringLiteral', isToken: true },
|
||||
<any>{ name: 'closeParenToken', isToken: true, excludeFromAST: true }
|
||||
],
|
||||
isTypeScriptSpecific: true
|
||||
@@ -79,7 +78,7 @@ var definitions:ITypeDefinition[] = [
|
||||
children: [
|
||||
<any>{ name: 'modifiers', isList: true, elementType: 'ISyntaxToken' },
|
||||
<any>{ name: 'importKeyword', isToken: true, excludeFromAST: true },
|
||||
<any>{ name: 'identifier', isToken: true, tokenKinds: ['IdentifierName'] },
|
||||
<any>{ name: 'identifier', isToken: true },
|
||||
<any>{ name: 'equalsToken', isToken: true, excludeFromAST: true },
|
||||
<any>{ name: 'moduleReference', type: 'IModuleReferenceSyntax' },
|
||||
<any>{ name: 'semicolonToken', isToken: true, isOptional: true, excludeFromAST: true }
|
||||
@@ -93,7 +92,7 @@ var definitions:ITypeDefinition[] = [
|
||||
children: [
|
||||
<any>{ name: 'exportKeyword', isToken: true, excludeFromAST: true },
|
||||
<any>{ name: 'equalsToken', isToken: true, excludeFromAST: true },
|
||||
<any>{ name: 'identifier', isToken: true, tokenKinds: ['IdentifierName'] },
|
||||
<any>{ name: 'identifier', isToken: true },
|
||||
<any>{ name: 'semicolonToken', isToken: true, isOptional: true, excludeFromAST: true }
|
||||
],
|
||||
isTypeScriptSpecific: true
|
||||
@@ -105,7 +104,7 @@ var definitions:ITypeDefinition[] = [
|
||||
children: [
|
||||
<any>{ name: 'modifiers', isList: true, elementType: 'ISyntaxToken' },
|
||||
<any>{ name: 'classKeyword', isToken: true, excludeFromAST: true },
|
||||
<any>{ name: 'identifier', isToken: true, tokenKinds: ['IdentifierName'] },
|
||||
<any>{ name: 'identifier', isToken: true },
|
||||
<any>{ name: 'typeParameterList', type: 'TypeParameterListSyntax', isOptional: true },
|
||||
<any>{ name: 'heritageClauses', isList: true, elementType: 'HeritageClauseSyntax' },
|
||||
<any>{ name: 'openBraceToken', isToken: true, excludeFromAST: true },
|
||||
@@ -121,7 +120,7 @@ var definitions:ITypeDefinition[] = [
|
||||
children: [
|
||||
<any>{ name: 'modifiers', isList: true, elementType: 'ISyntaxToken' },
|
||||
<any>{ name: 'interfaceKeyword', isToken: true, excludeFromAST: true },
|
||||
<any>{ name: 'identifier', isToken: true, tokenKinds: ['IdentifierName'] },
|
||||
<any>{ name: 'identifier', isToken: true },
|
||||
<any>{ name: 'typeParameterList', type: 'TypeParameterListSyntax', isOptional: true },
|
||||
<any>{ name: 'heritageClauses', isList: true, elementType: 'HeritageClauseSyntax' },
|
||||
<any>{ name: 'body', type: 'ObjectTypeSyntax' }
|
||||
@@ -158,7 +157,8 @@ var definitions:ITypeDefinition[] = [
|
||||
children: [
|
||||
<any>{ name: 'modifiers', isList: true, elementType: 'ISyntaxToken', isTypeScriptSpecific: true },
|
||||
<any>{ name: 'functionKeyword', isToken: true, excludeFromAST: true },
|
||||
<any>{ name: 'identifier', isToken: true, tokenKinds: ['IdentifierName'] },
|
||||
<any>{ name: 'asterixToken', isToken: true, isOptional: true },
|
||||
<any>{ name: 'identifier', isToken: true },
|
||||
<any>{ name: 'callSignature', type: 'CallSignatureSyntax' },
|
||||
<any>{ name: 'body', type: 'BlockSyntax | ISyntaxToken', isOptional: true }
|
||||
]
|
||||
@@ -262,7 +262,7 @@ var definitions:ITypeDefinition[] = [
|
||||
children: [
|
||||
<any>{ name: 'left', type: 'INameSyntax' },
|
||||
<any>{ name: 'dotToken', isToken: true, excludeFromAST: true },
|
||||
<any>{ name: 'right', isToken: true, tokenKinds:['IdentifierName'] }
|
||||
<any>{ name: 'right', isToken: true }
|
||||
],
|
||||
// Qualified names only show up in Types, which are TypeScript specific. Note that a dotted
|
||||
// expression (like A.B.Foo()) is a MemberAccessExpression, not a QualifiedName.
|
||||
@@ -403,7 +403,7 @@ var definitions:ITypeDefinition[] = [
|
||||
children: [
|
||||
<any>{ name: 'dotDotDotToken', isToken: true, isOptional: true, isTypeScriptSpecific: true },
|
||||
<any>{ name: 'modifiers', isList: true, elementType: 'ISyntaxToken' },
|
||||
<any>{ name: 'identifier', isToken: true, tokenKinds: ['IdentifierName'] },
|
||||
<any>{ name: 'identifier', isToken: true },
|
||||
<any>{ name: 'questionToken', isToken: true, isOptional: true, isTypeScriptSpecific: true },
|
||||
<any>{ name: 'typeAnnotation', type: 'TypeAnnotationSyntax', isOptional: true, isTypeScriptSpecific: true },
|
||||
<any>{ name: 'equalsValueClause', type: 'EqualsValueClauseSyntax', isOptional: true, isTypeScriptSpecific: true }
|
||||
@@ -416,7 +416,7 @@ var definitions:ITypeDefinition[] = [
|
||||
children: [
|
||||
<any>{ name: 'expression', type: 'ILeftHandSideExpressionSyntax' },
|
||||
<any>{ name: 'dotToken', isToken: true, excludeFromAST: true },
|
||||
<any>{ name: 'name', isToken: true, tokenKinds: ['IdentifierName'] }
|
||||
<any>{ name: 'name', isToken: true }
|
||||
]
|
||||
},
|
||||
<any>{
|
||||
@@ -582,7 +582,7 @@ var definitions:ITypeDefinition[] = [
|
||||
name: 'TypeParameterSyntax',
|
||||
baseType: 'ISyntaxNode',
|
||||
children: [
|
||||
<any>{ name: 'identifier', isToken: true, tokenKinds: ['IdentifierName'] },
|
||||
<any>{ name: 'identifier', isToken: true },
|
||||
<any>{ name: 'constraint', type: 'ConstraintSyntax', isOptional: true }
|
||||
],
|
||||
isTypeScriptSpecific: true
|
||||
@@ -645,6 +645,7 @@ var definitions:ITypeDefinition[] = [
|
||||
interfaces: ['IMemberDeclarationSyntax'],
|
||||
children: [
|
||||
<any>{ name: 'modifiers', isList: true, elementType: 'ISyntaxToken' },
|
||||
<any>{ name: 'asterixToken', isToken: true, isOptional: true },
|
||||
<any>{ name: 'propertyName', type: 'IPropertyNameSyntax' },
|
||||
<any>{ name: 'callSignature', type: 'CallSignatureSyntax' },
|
||||
<any>{ name: 'body', type: 'BlockSyntax | ISyntaxToken', isOptional: true }
|
||||
@@ -769,7 +770,7 @@ var definitions:ITypeDefinition[] = [
|
||||
interfaces: ['IStatementSyntax'],
|
||||
children: [
|
||||
<any>{ name: 'breakKeyword', isToken: true },
|
||||
<any>{ name: 'identifier', isToken: true, isOptional: true, tokenKinds: ['IdentifierName'] },
|
||||
<any>{ name: 'identifier', isToken: true, isOptional: true },
|
||||
<any>{ name: 'semicolonToken', isToken: true, isOptional: true, excludeFromAST: true }
|
||||
]
|
||||
},
|
||||
@@ -779,7 +780,7 @@ var definitions:ITypeDefinition[] = [
|
||||
interfaces: ['IStatementSyntax'],
|
||||
children: [
|
||||
<any>{ name: 'continueKeyword', isToken: true },
|
||||
<any>{ name: 'identifier', isToken: true, isOptional: true, tokenKinds: ['IdentifierName'] },
|
||||
<any>{ name: 'identifier', isToken: true, isOptional: true },
|
||||
<any>{ name: 'semicolonToken', isToken: true, isOptional: true, excludeFromAST: true }
|
||||
]
|
||||
},
|
||||
@@ -791,9 +792,9 @@ var definitions:ITypeDefinition[] = [
|
||||
<any>{ name: 'forKeyword', isToken: true, excludeFromAST: true },
|
||||
<any>{ name: 'openParenToken', isToken: true, excludeFromAST: true },
|
||||
<any>{ name: 'initializer', type: 'VariableDeclarationSyntax | IExpressionSyntax', isOptional: true },
|
||||
<any>{ name: 'firstSemicolonToken', isToken: true, tokenKinds: ['SemicolonToken'], excludeFromAST: true },
|
||||
<any>{ name: 'firstSemicolonToken', isToken: true, excludeFromAST: true },
|
||||
<any>{ name: 'condition', type: 'IExpressionSyntax', isOptional: true },
|
||||
<any>{ name: 'secondSemicolonToken', isToken: true, tokenKinds: ['SemicolonToken'], excludeFromAST: true },
|
||||
<any>{ name: 'secondSemicolonToken', isToken: true, excludeFromAST: true },
|
||||
<any>{ name: 'incrementor', type: 'IExpressionSyntax', isOptional: true },
|
||||
<any>{ name: 'closeParenToken', isToken: true, excludeFromAST: true },
|
||||
<any>{ name: 'statement', type: 'IStatementSyntax' }
|
||||
@@ -844,7 +845,7 @@ var definitions:ITypeDefinition[] = [
|
||||
children: [
|
||||
<any>{ name: 'modifiers', isList: true, elementType: 'ISyntaxToken' },
|
||||
<any>{ name: 'enumKeyword', isToken: true, excludeFromAST: true },
|
||||
<any>{ name: 'identifier', isToken: true, tokenKinds: ['IdentifierName'] },
|
||||
<any>{ name: 'identifier', isToken: true },
|
||||
<any>{ name: 'openBraceToken', isToken: true, excludeFromAST: true },
|
||||
<any>{ name: 'enumElements', isSeparatedList: true, elementType: 'EnumElementSyntax' },
|
||||
<any>{ name: 'closeBraceToken', isToken: true, excludeFromAST: true }
|
||||
@@ -917,7 +918,8 @@ var definitions:ITypeDefinition[] = [
|
||||
interfaces: ['IPrimaryExpressionSyntax'],
|
||||
children: [
|
||||
<any>{ name: 'functionKeyword', isToken: true, excludeFromAST: true },
|
||||
<any>{ name: 'identifier', isToken: true, isOptional: true, tokenKinds: ['IdentifierName'] },
|
||||
<any>{ name: 'asterixToken', isToken: true, isOptional: true },
|
||||
<any>{ name: 'identifier', isToken: true, isOptional: true },
|
||||
<any>{ name: 'callSignature', type: 'CallSignatureSyntax' },
|
||||
<any>{ name: 'block', type: 'BlockSyntax' }]
|
||||
},
|
||||
@@ -944,7 +946,7 @@ var definitions:ITypeDefinition[] = [
|
||||
children: [
|
||||
<any>{ name: 'catchKeyword', isToken: true, excludeFromAST: true },
|
||||
<any>{ name: 'openParenToken', isToken: true, excludeFromAST: true },
|
||||
<any>{ name: 'identifier', isToken: true, tokenKinds: ['IdentifierName'] },
|
||||
<any>{ name: 'identifier', isToken: true },
|
||||
<any>{ name: 'typeAnnotation', type: 'TypeAnnotationSyntax', isOptional: true, isTypeScriptSpecified: true },
|
||||
<any>{ name: 'closeParenToken', isToken: true, excludeFromAST: true },
|
||||
<any>{ name: 'block', type: 'BlockSyntax' }]
|
||||
@@ -961,7 +963,7 @@ var definitions:ITypeDefinition[] = [
|
||||
baseType: 'ISyntaxNode',
|
||||
interfaces: ['IStatementSyntax'],
|
||||
children: [
|
||||
<any>{ name: 'identifier', isToken: true, tokenKinds: ['IdentifierName'] },
|
||||
<any>{ name: 'identifier', isToken: true },
|
||||
<any>{ name: 'colonToken', isToken: true, excludeFromAST: true },
|
||||
<any>{ name: 'statement', type: 'IStatementSyntax' }]
|
||||
},
|
||||
|
||||
@@ -92,11 +92,12 @@ module TypeScript {
|
||||
export interface FunctionDeclarationSyntax extends ISyntaxNode, IStatementSyntax {
|
||||
modifiers: ISyntaxToken[];
|
||||
functionKeyword: ISyntaxToken;
|
||||
asterixToken: ISyntaxToken;
|
||||
identifier: ISyntaxToken;
|
||||
callSignature: CallSignatureSyntax;
|
||||
body: BlockSyntax | ISyntaxToken;
|
||||
}
|
||||
export interface FunctionDeclarationConstructor { new (data: number, modifiers: ISyntaxToken[], functionKeyword: ISyntaxToken, identifier: ISyntaxToken, callSignature: CallSignatureSyntax, body: BlockSyntax | ISyntaxToken): FunctionDeclarationSyntax }
|
||||
export interface FunctionDeclarationConstructor { new (data: number, modifiers: ISyntaxToken[], functionKeyword: ISyntaxToken, asterixToken: ISyntaxToken, identifier: ISyntaxToken, callSignature: CallSignatureSyntax, body: BlockSyntax | ISyntaxToken): FunctionDeclarationSyntax }
|
||||
|
||||
export interface ModuleDeclarationSyntax extends ISyntaxNode, IModuleElementSyntax {
|
||||
modifiers: ISyntaxToken[];
|
||||
@@ -150,11 +151,12 @@ module TypeScript {
|
||||
|
||||
export interface MemberFunctionDeclarationSyntax extends ISyntaxNode, IMemberDeclarationSyntax {
|
||||
modifiers: ISyntaxToken[];
|
||||
asterixToken: ISyntaxToken;
|
||||
propertyName: IPropertyNameSyntax;
|
||||
callSignature: CallSignatureSyntax;
|
||||
body: BlockSyntax | ISyntaxToken;
|
||||
}
|
||||
export interface MemberFunctionDeclarationConstructor { new (data: number, modifiers: ISyntaxToken[], propertyName: IPropertyNameSyntax, callSignature: CallSignatureSyntax, body: BlockSyntax | ISyntaxToken): MemberFunctionDeclarationSyntax }
|
||||
export interface MemberFunctionDeclarationConstructor { new (data: number, modifiers: ISyntaxToken[], asterixToken: ISyntaxToken, propertyName: IPropertyNameSyntax, callSignature: CallSignatureSyntax, body: BlockSyntax | ISyntaxToken): MemberFunctionDeclarationSyntax }
|
||||
|
||||
export interface MemberVariableDeclarationSyntax extends ISyntaxNode, IMemberDeclarationSyntax {
|
||||
modifiers: ISyntaxToken[];
|
||||
@@ -498,11 +500,12 @@ module TypeScript {
|
||||
|
||||
export interface FunctionExpressionSyntax extends ISyntaxNode, IPrimaryExpressionSyntax {
|
||||
functionKeyword: ISyntaxToken;
|
||||
asterixToken: ISyntaxToken;
|
||||
identifier: ISyntaxToken;
|
||||
callSignature: CallSignatureSyntax;
|
||||
block: BlockSyntax;
|
||||
}
|
||||
export interface FunctionExpressionConstructor { new (data: number, functionKeyword: ISyntaxToken, identifier: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax): FunctionExpressionSyntax }
|
||||
export interface FunctionExpressionConstructor { new (data: number, functionKeyword: ISyntaxToken, asterixToken: ISyntaxToken, identifier: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax): FunctionExpressionSyntax }
|
||||
|
||||
export interface OmittedExpressionSyntax extends ISyntaxNode, IExpressionSyntax {
|
||||
}
|
||||
|
||||
@@ -238,28 +238,31 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var FunctionDeclarationSyntax: FunctionDeclarationConstructor = <any>function(data: number, modifiers: ISyntaxToken[], functionKeyword: ISyntaxToken, identifier: ISyntaxToken, callSignature: CallSignatureSyntax, body: BlockSyntax | ISyntaxToken) {
|
||||
export var FunctionDeclarationSyntax: FunctionDeclarationConstructor = <any>function(data: number, modifiers: ISyntaxToken[], functionKeyword: ISyntaxToken, asterixToken: ISyntaxToken, identifier: ISyntaxToken, callSignature: CallSignatureSyntax, body: BlockSyntax | ISyntaxToken) {
|
||||
if (data) { this.__data = data; }
|
||||
this.modifiers = modifiers,
|
||||
this.functionKeyword = functionKeyword,
|
||||
this.asterixToken = asterixToken,
|
||||
this.identifier = identifier,
|
||||
this.callSignature = callSignature,
|
||||
this.body = body,
|
||||
modifiers.parent = this,
|
||||
functionKeyword.parent = this,
|
||||
asterixToken && (asterixToken.parent = this),
|
||||
identifier.parent = this,
|
||||
callSignature.parent = this,
|
||||
body && (body.parent = this);
|
||||
};
|
||||
FunctionDeclarationSyntax.prototype.kind = SyntaxKind.FunctionDeclaration;
|
||||
FunctionDeclarationSyntax.prototype.childCount = 5;
|
||||
FunctionDeclarationSyntax.prototype.childCount = 6;
|
||||
FunctionDeclarationSyntax.prototype.childAt = function(index: number): ISyntaxElement {
|
||||
switch (index) {
|
||||
case 0: return this.modifiers;
|
||||
case 1: return this.functionKeyword;
|
||||
case 2: return this.identifier;
|
||||
case 3: return this.callSignature;
|
||||
case 4: return this.body;
|
||||
case 2: return this.asterixToken;
|
||||
case 3: return this.identifier;
|
||||
case 4: return this.callSignature;
|
||||
case 5: return this.body;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -403,25 +406,28 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var MemberFunctionDeclarationSyntax: MemberFunctionDeclarationConstructor = <any>function(data: number, modifiers: ISyntaxToken[], propertyName: IPropertyNameSyntax, callSignature: CallSignatureSyntax, body: BlockSyntax | ISyntaxToken) {
|
||||
export var MemberFunctionDeclarationSyntax: MemberFunctionDeclarationConstructor = <any>function(data: number, modifiers: ISyntaxToken[], asterixToken: ISyntaxToken, propertyName: IPropertyNameSyntax, callSignature: CallSignatureSyntax, body: BlockSyntax | ISyntaxToken) {
|
||||
if (data) { this.__data = data; }
|
||||
this.modifiers = modifiers,
|
||||
this.asterixToken = asterixToken,
|
||||
this.propertyName = propertyName,
|
||||
this.callSignature = callSignature,
|
||||
this.body = body,
|
||||
modifiers.parent = this,
|
||||
asterixToken && (asterixToken.parent = this),
|
||||
propertyName.parent = this,
|
||||
callSignature.parent = this,
|
||||
body && (body.parent = this);
|
||||
};
|
||||
MemberFunctionDeclarationSyntax.prototype.kind = SyntaxKind.MemberFunctionDeclaration;
|
||||
MemberFunctionDeclarationSyntax.prototype.childCount = 4;
|
||||
MemberFunctionDeclarationSyntax.prototype.childCount = 5;
|
||||
MemberFunctionDeclarationSyntax.prototype.childAt = function(index: number): ISyntaxElement {
|
||||
switch (index) {
|
||||
case 0: return this.modifiers;
|
||||
case 1: return this.propertyName;
|
||||
case 2: return this.callSignature;
|
||||
case 3: return this.body;
|
||||
case 1: return this.asterixToken;
|
||||
case 2: return this.propertyName;
|
||||
case 3: return this.callSignature;
|
||||
case 4: return this.body;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1355,25 +1361,28 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var FunctionExpressionSyntax: FunctionExpressionConstructor = <any>function(data: number, functionKeyword: ISyntaxToken, identifier: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax) {
|
||||
export var FunctionExpressionSyntax: FunctionExpressionConstructor = <any>function(data: number, functionKeyword: ISyntaxToken, asterixToken: ISyntaxToken, identifier: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax) {
|
||||
if (data) { this.__data = data; }
|
||||
this.functionKeyword = functionKeyword,
|
||||
this.asterixToken = asterixToken,
|
||||
this.identifier = identifier,
|
||||
this.callSignature = callSignature,
|
||||
this.block = block,
|
||||
functionKeyword.parent = this,
|
||||
asterixToken && (asterixToken.parent = this),
|
||||
identifier && (identifier.parent = this),
|
||||
callSignature.parent = this,
|
||||
block.parent = this;
|
||||
};
|
||||
FunctionExpressionSyntax.prototype.kind = SyntaxKind.FunctionExpression;
|
||||
FunctionExpressionSyntax.prototype.childCount = 4;
|
||||
FunctionExpressionSyntax.prototype.childCount = 5;
|
||||
FunctionExpressionSyntax.prototype.childAt = function(index: number): ISyntaxElement {
|
||||
switch (index) {
|
||||
case 0: return this.functionKeyword;
|
||||
case 1: return this.identifier;
|
||||
case 2: return this.callSignature;
|
||||
case 3: return this.block;
|
||||
case 1: return this.asterixToken;
|
||||
case 2: return this.identifier;
|
||||
case 3: return this.callSignature;
|
||||
case 4: return this.block;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -97,6 +97,7 @@ module TypeScript {
|
||||
public visitFunctionDeclaration(node: FunctionDeclarationSyntax): void {
|
||||
this.visitList(node.modifiers);
|
||||
this.visitToken(node.functionKeyword);
|
||||
this.visitOptionalToken(node.asterixToken);
|
||||
this.visitToken(node.identifier);
|
||||
visitNodeOrToken(this, node.callSignature);
|
||||
visitNodeOrToken(this, node.body);
|
||||
@@ -149,6 +150,7 @@ module TypeScript {
|
||||
|
||||
public visitMemberFunctionDeclaration(node: MemberFunctionDeclarationSyntax): void {
|
||||
this.visitList(node.modifiers);
|
||||
this.visitOptionalToken(node.asterixToken);
|
||||
visitNodeOrToken(this, node.propertyName);
|
||||
visitNodeOrToken(this, node.callSignature);
|
||||
visitNodeOrToken(this, node.body);
|
||||
@@ -451,6 +453,7 @@ module TypeScript {
|
||||
|
||||
public visitFunctionExpression(node: FunctionExpressionSyntax): void {
|
||||
this.visitToken(node.functionKeyword);
|
||||
this.visitOptionalToken(node.asterixToken);
|
||||
this.visitOptionalToken(node.identifier);
|
||||
visitNodeOrToken(this, node.callSignature);
|
||||
visitNodeOrToken(this, node.block);
|
||||
|
||||
Reference in New Issue
Block a user