Merge pull request #1050 from Microsoft/incrementalPerf2

More incremental perf tweaks.
This commit is contained in:
CyrusNajmabadi 2014-11-04 01:27:54 -08:00
commit 47a3410324
25 changed files with 1332 additions and 1565 deletions

View File

@ -99,26 +99,26 @@ module TypeScript {
var start = new Date().getTime();
// Look for:
// import foo = module("foo")
while (token.kind() !== SyntaxKind.EndOfFileToken) {
if (token.kind() === SyntaxKind.ImportKeyword) {
while (token.kind !== SyntaxKind.EndOfFileToken) {
if (token.kind === SyntaxKind.ImportKeyword) {
var importToken = token;
token = scanner.scan(/*allowRegularExpression:*/ false);
if (SyntaxFacts.isIdentifierNameOrAnyKeyword(token)) {
token = scanner.scan(/*allowRegularExpression:*/ false);
if (token.kind() === SyntaxKind.EqualsToken) {
if (token.kind === SyntaxKind.EqualsToken) {
token = scanner.scan(/*allowRegularExpression:*/ false);
if (token.kind() === SyntaxKind.ModuleKeyword || token.kind() === SyntaxKind.RequireKeyword) {
if (token.kind === SyntaxKind.ModuleKeyword || token.kind === SyntaxKind.RequireKeyword) {
token = scanner.scan(/*allowRegularExpression:*/ false);
if (token.kind() === SyntaxKind.OpenParenToken) {
if (token.kind === SyntaxKind.OpenParenToken) {
token = scanner.scan(/*allowRegularExpression:*/ false);
lineMap.fillLineAndCharacterFromPosition(TypeScript.start(importToken, text), lineChar);
if (token.kind() === SyntaxKind.StringLiteral) {
if (token.kind === SyntaxKind.StringLiteral) {
var ref = {
line: lineChar.line,
character: lineChar.character,

View File

@ -78,7 +78,7 @@ module TypeScript.Services.Formatting {
}
// Push the token
var currentTokenSpan = new TokenSpan(token.kind(), position, width(token));
var currentTokenSpan = new TokenSpan(token.kind, position, width(token));
if (!this.parent().hasSkippedOrMissingTokenChild()) {
if (this.previousTokenSpan) {
// Note that formatPair calls TrimWhitespaceInLineRange in between the 2 tokens

View File

@ -42,12 +42,12 @@ module TypeScript.Services.Formatting {
var sourceUnit = this.syntaxTree.sourceUnit();
var semicolonPositionedToken = findToken(sourceUnit, caretPosition - 1);
if (semicolonPositionedToken.kind() === SyntaxKind.SemicolonToken) {
if (semicolonPositionedToken.kind === SyntaxKind.SemicolonToken) {
// Find the outer most parent that this semicolon terminates
var current: ISyntaxElement = semicolonPositionedToken;
while (current.parent !== null &&
end(current.parent) === end(semicolonPositionedToken) &&
current.parent.kind() !== SyntaxKind.List) {
current.parent.kind !== SyntaxKind.List) {
current = current.parent;
}
@ -65,12 +65,12 @@ module TypeScript.Services.Formatting {
var sourceUnit = this.syntaxTree.sourceUnit();
var closeBracePositionedToken = findToken(sourceUnit, caretPosition - 1);
if (closeBracePositionedToken.kind() === SyntaxKind.CloseBraceToken) {
if (closeBracePositionedToken.kind === SyntaxKind.CloseBraceToken) {
// Find the outer most parent that this closing brace terminates
var current: ISyntaxElement = closeBracePositionedToken;
while (current.parent !== null &&
end(current.parent) === end(closeBracePositionedToken) &&
current.parent.kind() !== SyntaxKind.List) {
current.parent.kind !== SyntaxKind.List) {
current = current.parent;
}

View File

@ -66,7 +66,7 @@ module TypeScript.Services.Formatting {
}
public kind(): SyntaxKind {
return this._node.kind();
return this._node.kind;
}
public hasSkippedOrMissingTokenChild(): boolean {

View File

@ -103,7 +103,7 @@ module TypeScript.Services.Formatting {
if (isToken(element)) {
this.visitToken(<ISyntaxToken>element);
}
else if (element.kind() === SyntaxKind.List) {
else if (element.kind === SyntaxKind.List) {
for (var i = 0, n = childCount(element); i < n; i++) {
this.walk(childAt(element, i));
}
@ -148,9 +148,9 @@ module TypeScript.Services.Formatting {
// }
// Also in a do-while statement, the while should be indented like the parent.
if (firstToken(this._parent.node()) === token ||
token.kind() === SyntaxKind.OpenBraceToken || token.kind() === SyntaxKind.CloseBraceToken ||
token.kind() === SyntaxKind.OpenBracketToken || token.kind() === SyntaxKind.CloseBracketToken ||
(token.kind() === SyntaxKind.WhileKeyword && this._parent.node().kind() == SyntaxKind.DoStatement)) {
token.kind === SyntaxKind.OpenBraceToken || token.kind === SyntaxKind.CloseBraceToken ||
token.kind === SyntaxKind.OpenBracketToken || token.kind === SyntaxKind.CloseBracketToken ||
(token.kind === SyntaxKind.WhileKeyword && this._parent.node().kind == SyntaxKind.DoStatement)) {
return this._parent.indentationAmount();
}
@ -161,7 +161,7 @@ module TypeScript.Services.Formatting {
// If this is token terminating an indentation scope, leading comments should be indented to follow the children
// indentation level and not the node
if (token.kind() === SyntaxKind.CloseBraceToken || token.kind() === SyntaxKind.CloseBracketToken) {
if (token.kind === SyntaxKind.CloseBraceToken || token.kind === SyntaxKind.CloseBracketToken) {
return (this._parent.indentationAmount() + this._parent.childIndentationAmountDelta());
}
return this._parent.indentationAmount();
@ -213,7 +213,7 @@ module TypeScript.Services.Formatting {
var indentationAmountDelta: number;
var parentNode = parent.node();
switch (node.kind()) {
switch (node.kind) {
default:
// General case
// This node should follow the child indentation set by its parent

View File

@ -119,7 +119,7 @@ module TypeScript.Services.Formatting {
}
if (token.kind() !== SyntaxKind.EndOfFileToken && indentNextTokenOrTrivia) {
if (token.kind !== SyntaxKind.EndOfFileToken && indentNextTokenOrTrivia) {
// If the last trivia item was a new line, or no trivia items were encounterd record the
// indentation edit at the token position
if (indentationString.length > 0) {

View File

@ -1982,7 +1982,7 @@ function generateConstructorFunction(definition) {
result += ";\r\n";
}
result += " };\r\n";
result += " " + definition.name + ".prototype.kind = function() { return SyntaxKind." + getNameWithoutSuffix(definition) + "; }\r\n";
result += " " + definition.name + ".prototype.kind = SyntaxKind." + getNameWithoutSuffix(definition) + ";\r\n";
return result;
}
function generateSyntaxInterfaces() {
@ -2154,16 +2154,28 @@ function max(array, func) {
}
return max;
}
function generateUtilities() {
var result = "";
result += " var fixedWidthArray = [";
for (var i = 0; i <= TypeScript.SyntaxKind.LastFixedWidth; i++) {
if (i) {
result += ", ";
}
if (i < TypeScript.SyntaxKind.FirstFixedWidth) {
result += "0";
}
else {
result += TypeScript.SyntaxFacts.getText(i).length;
}
}
result += "];\r\n";
result += " function fixedWidthTokenLength(kind: SyntaxKind) {\r\n";
result += " return fixedWidthArray[kind];\r\n";
result += " }\r\n";
return result;
}
function generateScannerUtilities() {
var result = "///<reference path='references.ts' />\r\n" + "\r\n" + "module TypeScript {\r\n" + " export module ScannerUtilities {\r\n";
result += " export function fixedWidthTokenLength(kind: SyntaxKind) {\r\n";
result += " switch (kind) {\r\n";
for (var k = TypeScript.SyntaxKind.FirstFixedWidth; k <= TypeScript.SyntaxKind.LastFixedWidth; k++) {
result += " case SyntaxKind." + syntaxKindName(k) + ": return " + TypeScript.SyntaxFacts.getText(k).length + ";\r\n";
}
result += " default: throw new Error();\r\n";
result += " }\r\n";
result += " }\r\n\r\n";
var i;
var keywords = [];
for (i = TypeScript.SyntaxKind.FirstKeyword; i <= TypeScript.SyntaxKind.LastKeyword; i++) {
@ -2202,7 +2214,7 @@ function generateVisitor() {
result += "module TypeScript {\r\n";
result += " export function visitNodeOrToken(visitor: ISyntaxVisitor, element: ISyntaxNodeOrToken): any {\r\n";
result += " if (element === undefined) { return undefined; }\r\n";
result += " switch (element.kind()) {\r\n";
result += " switch (element.kind) {\r\n";
for (var i = 0; i < definitions.length; i++) {
var definition = definitions[i];
result += " case SyntaxKind." + getNameWithoutSuffix(definition) + ": ";
@ -2240,31 +2252,38 @@ function generateServicesUtilities() {
result += "];\r\n\r\n";
result += " export function childCount(element: ISyntaxElement): number {\r\n";
result += " if (isList(element)) { return (<ISyntaxNodeOrToken[]>element).length; }\r\n";
result += " return childCountArray[element.kind()];\r\n";
result += " return childCountArray[element.kind];\r\n";
result += " }\r\n\r\n";
result += " var childAtArray: ((nodeOrToken: ISyntaxElement, index: number) => ISyntaxElement)[] = [\r\n ";
for (var i = 0; i < TypeScript.SyntaxKind.FirstNode; i++) {
if (i) {
result += ", ";
}
result += "undefined";
}
for (var i = 0; i < definitions.length; i++) {
var definition = definitions[i];
result += " function " + camelCase(getNameWithoutSuffix(definition)) + "ChildAt(node: " + definition.name + ", index: number): ISyntaxElement {\r\n";
result += ",\r\n";
result += " (node: " + definition.name + ", index: number): ISyntaxElement => {\r\n";
if (definition.children.length) {
result += " switch (index) {\r\n";
result += " switch (index) {\r\n";
for (var j = 0; j < definition.children.length; j++) {
result += " case " + j + ": return node." + definition.children[j].name + ";\r\n";
result += " case " + j + ": return node." + definition.children[j].name + ";\r\n";
}
result += " }\r\n";
result += " }\r\n";
}
else {
result += " throw Errors.invalidOperation();\r\n";
result += " throw Errors.invalidOperation();\r\n";
}
result += " }\r\n";
result += " }";
}
result += "\r\n ];\r\n";
result += " export function childAt(element: ISyntaxElement, index: number): ISyntaxElement {\r\n";
result += " if (isList(element)) { return (<ISyntaxNodeOrToken[]>element)[index]; }\r\n";
result += " switch (element.kind()) {\r\n";
for (var i = 0; i < definitions.length; i++) {
var definition = definitions[i];
result += " case SyntaxKind." + getNameWithoutSuffix(definition) + ": return " + camelCase(getNameWithoutSuffix(definition)) + "ChildAt(<" + definition.name + ">element, index);\r\n";
}
result += " }\r\n";
result += " return childAtArray[element.kind](element, index);\r\n";
result += " }\r\n\r\n";
result += " export function getChildAtFunction(element: ISyntaxNodeOrToken): (nodeOrToken: ISyntaxElement, index: number) => ISyntaxElement {\r\n";
result += " return childAtArray[element.kind];\r\n";
result += " }\r\n";
result += "}";
return result;
@ -2275,9 +2294,11 @@ var walker = generateWalker();
var scannerUtilities = generateScannerUtilities();
var visitor = generateVisitor();
var servicesUtilities = generateServicesUtilities();
var utilities = generateUtilities();
sys.writeFile(sys.getCurrentDirectory() + "\\src\\services\\syntax\\syntaxNodes.concrete.generated.ts", syntaxNodesConcrete, false);
sys.writeFile(sys.getCurrentDirectory() + "\\src\\services\\syntax\\syntaxInterfaces.generated.ts", syntaxInterfaces, false);
sys.writeFile(sys.getCurrentDirectory() + "\\src\\services\\syntax\\syntaxWalker.generated.ts", walker, false);
sys.writeFile(sys.getCurrentDirectory() + "\\src\\services\\syntax\\scannerUtilities.generated.ts", scannerUtilities, false);
sys.writeFile(sys.getCurrentDirectory() + "\\src\\services\\syntax\\syntaxVisitor.generated.ts", visitor, false);
sys.writeFile(sys.getCurrentDirectory() + "\\src\\services\\syntax\\syntaxUtilities.generated.ts", servicesUtilities, false);
sys.writeFile(sys.getCurrentDirectory() + "\\src\\services\\syntax\\utilities.generated.ts", utilities, false);

View File

@ -235,7 +235,20 @@ module TypeScript.IncrementalParser {
!_oldSourceUnitCursor.isFinished();
}
function updateTokens(nodeOrToken: ISyntaxNodeOrToken): void {
function updateTokenPosition(token: ISyntaxToken): void {
// If we got a node or token, and we're past the range of edited text, then walk its
// constituent tokens, making sure all their positions are correct. We don't need to
// do this for the tokens before the edited range (since their positions couldn't have
// been affected by the edit), and we don't need to do this for the tokens in the
// edited range, as their positions will be correct when the underlying parser source
// creates them.
if (isPastChangeRange()) {
token.setFullStart(absolutePosition());
}
}
function updateNodePosition(node: ISyntaxNode): void {
// If we got a node or token, and we're past the range of edited text, then walk its
// constituent tokens, making sure all their positions are correct. We don't need to
// do this for the tokens before the edited range (since their positions couldn't have
@ -246,18 +259,13 @@ module TypeScript.IncrementalParser {
if (isPastChangeRange()) {
var position = absolutePosition();
if (isToken(nodeOrToken)) {
(<ISyntaxToken>nodeOrToken).setFullStart(position);
}
else {
var tokens = getTokens(<ISyntaxNode>nodeOrToken);
var tokens = getTokens(node);
for (var i = 0, n = tokens.length; i < n; i++) {
var token = tokens[i];
token.setFullStart(position);
for (var i = 0, n = tokens.length; i < n; i++) {
var token = tokens[i];
token.setFullStart(position);
position += token.fullWidth();
}
position += token.fullWidth();
}
}
}
@ -284,7 +292,7 @@ module TypeScript.IncrementalParser {
var node = tryGetNodeFromOldSourceUnit();
if (node) {
// Make sure the positions for the tokens in this node are correct.
updateTokens(node);
updateNodePosition(node);
return node;
}
}
@ -298,7 +306,7 @@ module TypeScript.IncrementalParser {
var token = tryGetTokenFromOldSourceUnit();
if (token) {
// Make sure the token's position/text is correct.
updateTokens(token);
updateTokenPosition(token);
return token;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -20,7 +20,7 @@ module TypeScript.PrettyPrinter {
return 0;
}
if (lastToken(element1).kind() === SyntaxKind.CloseBraceToken) {
if (lastToken(element1).kind === SyntaxKind.CloseBraceToken) {
return 2;
}
@ -40,7 +40,7 @@ module TypeScript.PrettyPrinter {
return 0;
}
if (lastToken(element1).kind() === SyntaxKind.CloseBraceToken) {
if (lastToken(element1).kind === SyntaxKind.CloseBraceToken) {
return 2;
}
@ -552,7 +552,7 @@ module TypeScript.PrettyPrinter {
public visitBinaryExpression(node: BinaryExpressionSyntax): void {
visitNodeOrToken(this, node.left);
if (node.operatorToken.kind() !== SyntaxKind.CommaToken) {
if (node.operatorToken.kind !== SyntaxKind.CommaToken) {
this.ensureSpace();
}
@ -628,7 +628,7 @@ module TypeScript.PrettyPrinter {
}
private appendBlockOrStatement(node: IStatementSyntax): void {
if (node.kind() === SyntaxKind.Block) {
if (node.kind === SyntaxKind.Block) {
this.ensureSpace();
visitNodeOrToken(this, node);
}
@ -654,7 +654,7 @@ module TypeScript.PrettyPrinter {
this.ensureNewLine();
this.appendToken(node.elseKeyword);
if (node.statement.kind() === SyntaxKind.IfStatement) {
if (node.statement.kind === SyntaxKind.IfStatement) {
this.ensureSpace();
visitNodeOrToken(this, node.statement);
}
@ -774,7 +774,7 @@ module TypeScript.PrettyPrinter {
}
private appendSwitchClauseStatements(node: ISwitchClauseSyntax): void {
if (childCount(node.statements) === 1 && childAt(node.statements, 0).kind() === SyntaxKind.Block) {
if (childCount(node.statements) === 1 && childAt(node.statements, 0).kind === SyntaxKind.Block) {
this.ensureSpace();
visitNodeOrToken(this, node.statements[0]);
}

View File

@ -60,84 +60,52 @@ module TypeScript.Scanner {
// This gives us 23bit for width (or 8MB of width which should be enough for any codebase).
enum ScannerConstants {
LargeTokenFullStartShift = 4,
LargeTokenFullWidthShift = 7,
LargeTokenLeadingTriviaBitMask = 0x01, // 00000001
LargeTokenLeadingCommentBitMask = 0x02, // 00000010
LargeTokenTrailingTriviaBitMask = 0x04, // 00000100
LargeTokenTrailingCommentBitMask = 0x08, // 00001000
LargeTokenTriviaBitMask = 0x0F, // 00001111
LargeTokenFullWidthShift = 6,
LargeTokenLeadingTriviaShift = 3,
FixedWidthTokenFullStartShift = 7,
FixedWidthTokenMaxFullStart = 0x7FFFFF, // 23 ones.
WhitespaceTrivia = 0x01, // 00000001
NewlineTrivia = 0x02, // 00000010
CommentTrivia = 0x04, // 00000100
TriviaMask = 0x07, // 00000111
SmallTokenFullWidthShift = 7,
SmallTokenFullStartShift = 12,
SmallTokenMaxFullStart = 0x3FFFF, // 18 ones.
SmallTokenMaxFullWidth = 0x1F, // 5 ones
SmallTokenFullWidthMask = 0x1F, // 00011111
KindMask = 0x7F, // 01111111
IsVariableWidthMask = 0x80, // 10000000
KindMask = 0x7F, // 01111111
IsVariableWidthMask = 0x80, // 10000000
}
// Make sure our math works for packing/unpacking large fullStarts.
Debug.assert(largeTokenUnpackFullStart(largeTokenPackFullStartAndInfo(1 << 26, 3)) === (1 << 26));
Debug.assert(largeTokenUnpackFullStart(largeTokenPackFullStartAndInfo(3 << 25, 1)) === (3 << 25));
Debug.assert(largeTokenUnpackFullStart(largeTokenPackFullStartAndInfo(10 << 23, 2)) === (10 << 23));
function fixedWidthTokenPackData(fullStart: number, kind: SyntaxKind) {
return (fullStart << ScannerConstants.FixedWidthTokenFullStartShift) | kind;
function largeTokenPackData(fullWidth: number, leadingTriviaInfo: number, trailingTriviaInfo: number) {
return (fullWidth << ScannerConstants.LargeTokenFullWidthShift) | (leadingTriviaInfo << ScannerConstants.LargeTokenLeadingTriviaShift) | trailingTriviaInfo;
}
function fixedWidthTokenUnpackFullStart(packedData: number) {
return packedData >> ScannerConstants.FixedWidthTokenFullStartShift;
function largeTokenUnpackFullWidth(packedFullWidthAndInfo: number): number {
return packedFullWidthAndInfo >> ScannerConstants.LargeTokenFullWidthShift;
}
function smallTokenPackData(fullStart: number, fullWidth: number, kind: SyntaxKind) {
return (fullStart << ScannerConstants.SmallTokenFullStartShift) |
(fullWidth << ScannerConstants.SmallTokenFullWidthShift) |
kind;
function largeTokenUnpackLeadingTriviaInfo(packedFullWidthAndInfo: number): number {
return (packedFullWidthAndInfo >> ScannerConstants.LargeTokenLeadingTriviaShift) & ScannerConstants.TriviaMask;
}
function smallTokenUnpackFullWidth(packedData: number): SyntaxKind {
return (packedData >> ScannerConstants.SmallTokenFullWidthShift) & ScannerConstants.SmallTokenFullWidthMask;
}
function smallTokenUnpackFullStart(packedData: number): number {
return packedData >> ScannerConstants.SmallTokenFullStartShift;
}
function largeTokenPackFullStartAndInfo(fullStart: number, triviaInfo: number): number {
return (fullStart << ScannerConstants.LargeTokenFullStartShift) | triviaInfo;
}
function largeTokenUnpackFullWidth(packedFullWidthAndKind: number) {
return packedFullWidthAndKind >> ScannerConstants.LargeTokenFullWidthShift;
}
function largeTokenUnpackFullStart(packedFullStartAndInfo: number): number {
return packedFullStartAndInfo >> ScannerConstants.LargeTokenFullStartShift;
function largeTokenUnpackTrailingTriviaInfo(packedFullWidthAndInfo: number): number {
return packedFullWidthAndInfo & ScannerConstants.TriviaMask;
}
function largeTokenUnpackHasLeadingTrivia(packed: number): boolean {
return (packed & ScannerConstants.LargeTokenLeadingTriviaBitMask) !== 0;
return largeTokenUnpackLeadingTriviaInfo(packed) !== 0;
}
function largeTokenUnpackHasTrailingTrivia(packed: number): boolean {
return (packed & ScannerConstants.LargeTokenTrailingTriviaBitMask) !== 0;
return largeTokenUnpackTrailingTriviaInfo(packed) !== 0;
}
function hasComment(info: number) {
return (info & ScannerConstants.CommentTrivia) !== 0;
}
function largeTokenUnpackHasLeadingComment(packed: number): boolean {
return (packed & ScannerConstants.LargeTokenLeadingCommentBitMask) !== 0;
return hasComment(largeTokenUnpackLeadingTriviaInfo(packed));
}
function largeTokenUnpackHasTrailingComment(packed: number): boolean {
return (packed & ScannerConstants.LargeTokenTrailingCommentBitMask) !== 0;
}
function largeTokenUnpackTriviaInfo(packed: number): number {
return packed & ScannerConstants.LargeTokenTriviaBitMask;
return hasComment(largeTokenUnpackTrailingTriviaInfo(packed));
}
var isKeywordStartCharacter: number[] = ArrayUtilities.createArray<number>(CharacterCodes.maxAsciiCharacter, 0);
@ -166,7 +134,7 @@ module TypeScript.Scanner {
// These tokens are contextually created based on parsing decisions. We can't reuse
// them in incremental scenarios as we may be in a context where the parser would not
// create them.
switch (token.kind()) {
switch (token.kind) {
// Created by the parser when it sees / or /= in a location where it needs an expression.
case SyntaxKind.RegularExpressionLiteral:
@ -254,11 +222,11 @@ module TypeScript.Scanner {
public _primaryExpressionBrand: any; public _memberExpressionBrand: any; public _leftHandSideExpressionBrand: any; public _postfixExpressionBrand: any; public _unaryExpressionBrand: any; public _expressionBrand: any; public _typeBrand: any; public _syntaxNodeOrTokenBrand: any;
public parent: ISyntaxElement;
constructor(private _packedData: number) {
constructor(private _fullStart: number, public kind: SyntaxKind) {
}
public setFullStart(fullStart: number): void {
this._packedData = fixedWidthTokenPackData(fullStart, this.kind());
this._fullStart = fullStart;
}
public childCount() { return 0 }
@ -268,21 +236,20 @@ module TypeScript.Scanner {
public isIncrementallyUnusable(): boolean { return false; }
public isKeywordConvertedToIdentifier(): boolean { return false; }
public hasSkippedToken(): boolean { return false; }
public fullText(): string { return SyntaxFacts.getText(this.kind()); }
public fullText(): string { return SyntaxFacts.getText(this.kind); }
public text(): string { return this.fullText(); }
public leadingTrivia(): ISyntaxTriviaList { return Syntax.emptyTriviaList; }
public trailingTrivia(): ISyntaxTriviaList { return Syntax.emptyTriviaList; }
public leadingTriviaWidth(): number { return 0; }
public trailingTriviaWidth(): number { return 0; }
public kind(): SyntaxKind { return this._packedData & ScannerConstants.KindMask; }
public fullWidth(): number { return fixedWidthTokenLength(this._packedData & ScannerConstants.KindMask); }
public fullStart(): number { return fixedWidthTokenUnpackFullStart(this._packedData); }
public fullWidth(): number { return fixedWidthTokenLength(this.kind); }
public fullStart(): number { return this._fullStart; }
public hasLeadingTrivia(): boolean { return false; }
public hasTrailingTrivia(): boolean { return false; }
public hasLeadingComment(): boolean { return false; }
public hasTrailingComment(): boolean { return false; }
public clone(): ISyntaxToken { return new FixedWidthTokenWithNoTrivia(this._packedData); }
public clone(): ISyntaxToken { return new FixedWidthTokenWithNoTrivia(this._fullStart, this.kind); }
}
class LargeScannerToken implements ISyntaxToken {
@ -291,15 +258,14 @@ module TypeScript.Scanner {
private cachedText: string;
constructor(private _packedFullStartAndInfo: number, private _packedFullWidthAndKind: number, cachedText: string) {
constructor(private _fullStart: number, public kind: SyntaxKind, private _packedFullWidthAndInfo: number, cachedText: string) {
if (cachedText !== undefined) {
this.cachedText = cachedText;
}
}
public setFullStart(fullStart: number): void {
this._packedFullStartAndInfo = largeTokenPackFullStartAndInfo(fullStart,
largeTokenUnpackTriviaInfo(this._packedFullStartAndInfo));
this._fullStart = fullStart;
}
public childCount() { return 0 }
@ -322,7 +288,7 @@ module TypeScript.Scanner {
public text(): string {
var cachedText = this.cachedText;
return cachedText !== undefined ? cachedText : SyntaxFacts.getText(this.kind());
return cachedText !== undefined ? cachedText : SyntaxFacts.getText(this.kind);
}
public leadingTrivia(text?: ISimpleText): ISyntaxTriviaList { return leadingTrivia(this, this.syntaxTreeText(text)); }
@ -336,14 +302,13 @@ module TypeScript.Scanner {
return trailingTriviaWidth(this, this.syntaxTreeText(text));
}
public kind(): SyntaxKind { return this._packedFullWidthAndKind & ScannerConstants.KindMask; }
public fullWidth(): number { return largeTokenUnpackFullWidth(this._packedFullWidthAndKind); }
public fullStart(): number { return largeTokenUnpackFullStart(this._packedFullStartAndInfo); }
public hasLeadingTrivia(): boolean { return largeTokenUnpackHasLeadingTrivia(this._packedFullStartAndInfo); }
public hasTrailingTrivia(): boolean { return largeTokenUnpackHasTrailingTrivia(this._packedFullStartAndInfo); }
public hasLeadingComment(): boolean { return largeTokenUnpackHasLeadingComment(this._packedFullStartAndInfo); }
public hasTrailingComment(): boolean { return largeTokenUnpackHasTrailingComment(this._packedFullStartAndInfo); }
public clone(): ISyntaxToken { return new LargeScannerToken(this._packedFullStartAndInfo, this._packedFullWidthAndKind, this.cachedText); }
public fullWidth(): number { return largeTokenUnpackFullWidth(this._packedFullWidthAndInfo); }
public fullStart(): number { return this._fullStart; }
public hasLeadingTrivia(): boolean { return largeTokenUnpackHasLeadingTrivia(this._packedFullWidthAndInfo); }
public hasTrailingTrivia(): boolean { return largeTokenUnpackHasTrailingTrivia(this._packedFullWidthAndInfo); }
public hasLeadingComment(): boolean { return largeTokenUnpackHasLeadingComment(this._packedFullWidthAndInfo); }
public hasTrailingComment(): boolean { return largeTokenUnpackHasTrailingComment(this._packedFullWidthAndInfo); }
public clone(): ISyntaxToken { return new LargeScannerToken(this._fullStart, this.kind, this._packedFullWidthAndInfo, this.cachedText); }
}
export interface DiagnosticCallback {
@ -384,12 +349,13 @@ module TypeScript.Scanner {
}
function reset(_text: ISimpleText, _start: number, _end: number) {
Debug.assert(_start <= _text.length(), "Token's start was not within the bounds of text: " + _start + " - [0, " + _text.length() + ")");
Debug.assert(_end <= _text.length(), "Token's end was not within the bounds of text: " + _end + " - [0, " + _text.length() + ")");
var textLength = _text.length();
Debug.assert(_start <= textLength, "Token's start was not within the bounds of text.");
Debug.assert(_end <= textLength, "Token's end was not within the bounds of text:");
if (!str || text !== _text) {
text = _text;
str = _text.substr(0, _text.length());
str = _text.substr(0, textLength);
}
start = _start;
@ -416,20 +382,14 @@ module TypeScript.Scanner {
((kindAndIsVariableWidth & ScannerConstants.IsVariableWidthMask) === 0);
if (isFixedWidth &&
leadingTriviaInfo === 0 && trailingTriviaInfo === 0 &&
fullStart <= ScannerConstants.FixedWidthTokenMaxFullStart &&
(kindAndIsVariableWidth & ScannerConstants.IsVariableWidthMask) === 0) {
leadingTriviaInfo === 0 && trailingTriviaInfo === 0) {
return new FixedWidthTokenWithNoTrivia((fullStart << ScannerConstants.FixedWidthTokenFullStartShift) | kind);
return new FixedWidthTokenWithNoTrivia(fullStart, kind);
}
else {
// inline the packing logic for perf.
var packedFullStartAndTriviaInfo = (fullStart << ScannerConstants.LargeTokenFullStartShift) |
leadingTriviaInfo | (trailingTriviaInfo << 2);
var packedFullWidthAndKind = (fullWidth << ScannerConstants.LargeTokenFullWidthShift) | kind;
var packedFullWidthAndInfo = largeTokenPackData(fullWidth, leadingTriviaInfo, trailingTriviaInfo);
var cachedText = isFixedWidth ? undefined : text.substr(start, end - start);
return new LargeScannerToken(packedFullStartAndTriviaInfo, packedFullWidthAndKind, cachedText);
return new LargeScannerToken(fullStart, kind, packedFullWidthAndInfo, cachedText);
}
}
@ -539,7 +499,7 @@ module TypeScript.Scanner {
case CharacterCodes.formFeed:
index++;
// we have trivia
result |= 1;
result |= ScannerConstants.WhitespaceTrivia;
continue;
case CharacterCodes.carriageReturn:
@ -548,10 +508,12 @@ module TypeScript.Scanner {
}
// fall through.
case CharacterCodes.lineFeed:
case CharacterCodes.paragraphSeparator:
case CharacterCodes.lineSeparator:
index++;
// we have trivia
result |= 1;
result |= ScannerConstants.NewlineTrivia;
// If we're consuming leading trivia, then we will continue consuming more
// trivia (including newlines) up to the first token we see. If we're
@ -567,14 +529,14 @@ module TypeScript.Scanner {
var ch2 = str.charCodeAt(index + 1);
if (ch2 === CharacterCodes.slash) {
// we have a comment, and we have trivia
result |= 3;
result |= ScannerConstants.CommentTrivia;
skipSingleLineCommentTrivia();
continue;
}
if (ch2 === CharacterCodes.asterisk) {
// we have a comment, and we have trivia
result |= 3;
result |= ScannerConstants.CommentTrivia;
skipMultiLineCommentTrivia();
continue;
}
@ -584,8 +546,8 @@ module TypeScript.Scanner {
return result;
default:
if (ch > CharacterCodes.maxAsciiCharacter && slowScanTriviaInfo(ch)) {
result |= 1;
if (ch > CharacterCodes.maxAsciiCharacter && slowScanWhitespaceTriviaInfo(ch)) {
result |= ScannerConstants.WhitespaceTrivia;
continue;
}
@ -596,7 +558,7 @@ module TypeScript.Scanner {
return result;
}
function slowScanTriviaInfo(ch: number): boolean {
function slowScanWhitespaceTriviaInfo(ch: number): boolean {
switch (ch) {
case CharacterCodes.nonBreakingSpace:
case CharacterCodes.enQuad:
@ -614,8 +576,6 @@ module TypeScript.Scanner {
case CharacterCodes.narrowNoBreakSpace:
case CharacterCodes.ideographicSpace:
case CharacterCodes.byteOrderMark:
case CharacterCodes.paragraphSeparator:
case CharacterCodes.lineSeparator:
index++;
return true;
@ -1688,11 +1648,14 @@ module TypeScript.Scanner {
function resetToPosition(absolutePosition: number): void {
Debug.assert(absolutePosition <= text.length(), "Trying to set the position outside the bounds of the text!");
var resetBackward = absolutePosition <= _absolutePosition;
_absolutePosition = absolutePosition;
// First, remove any diagnostics that came after this position.
removeDiagnosticsOnOrAfterPosition(absolutePosition);
if (resetBackward) {
// First, remove any diagnostics that came after this position.
removeDiagnosticsOnOrAfterPosition(absolutePosition);
}
// Now, tell our sliding window to throw away all tokens after this position as well.
slidingWindow.disgardAllItemsFromCurrentIndexOnwards();
@ -1704,7 +1667,7 @@ module TypeScript.Scanner {
function currentContextualToken(): ISyntaxToken {
// We better be on a / or > token right now.
// Debug.assert(SyntaxFacts.isAnyDivideToken(currentToken().kind()));
// Debug.assert(SyntaxFacts.isAnyDivideToken(currentToken().kind));
// First, we're going to rewind all our data to the point where this / or /= token started.
// That's because if it does turn out to be a regular expression, then any tokens or token
@ -1724,7 +1687,7 @@ module TypeScript.Scanner {
// We have better gotten some sort of regex token. Otherwise, something *very* wrong has
// occurred.
// Debug.assert(SyntaxFacts.isAnyDivideOrRegularExpressionToken(token.kind()));
// Debug.assert(SyntaxFacts.isAnyDivideOrRegularExpressionToken(token.kind));
return token;
}
@ -1749,114 +1712,8 @@ module TypeScript.Scanner {
};
}
var fixedWidthArray = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 4, 5, 8, 8, 7, 6, 2, 4, 5, 7, 3, 8, 2, 2, 10, 3, 4, 6, 6, 4, 5, 4, 3, 6, 3, 4, 5, 4, 5, 5, 4, 6, 7, 6, 5, 10, 9, 3, 7, 7, 9, 6, 6, 5, 3, 7, 11, 7, 3, 6, 7, 6, 3, 6, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 1, 1, 1, 1, 2, 2, 2, 2, 3, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 2, 2, 2, 2, 3, 3, 4, 2, 2, 2, 1, 2];
function fixedWidthTokenLength(kind: SyntaxKind) {
switch (kind) {
case SyntaxKind.BreakKeyword: return 5;
case SyntaxKind.CaseKeyword: return 4;
case SyntaxKind.CatchKeyword: return 5;
case SyntaxKind.ContinueKeyword: return 8;
case SyntaxKind.DebuggerKeyword: return 8;
case SyntaxKind.DefaultKeyword: return 7;
case SyntaxKind.DeleteKeyword: return 6;
case SyntaxKind.DoKeyword: return 2;
case SyntaxKind.ElseKeyword: return 4;
case SyntaxKind.FalseKeyword: return 5;
case SyntaxKind.FinallyKeyword: return 7;
case SyntaxKind.ForKeyword: return 3;
case SyntaxKind.FunctionKeyword: return 8;
case SyntaxKind.IfKeyword: return 2;
case SyntaxKind.InKeyword: return 2;
case SyntaxKind.InstanceOfKeyword: return 10;
case SyntaxKind.NewKeyword: return 3;
case SyntaxKind.NullKeyword: return 4;
case SyntaxKind.ReturnKeyword: return 6;
case SyntaxKind.SwitchKeyword: return 6;
case SyntaxKind.ThisKeyword: return 4;
case SyntaxKind.ThrowKeyword: return 5;
case SyntaxKind.TrueKeyword: return 4;
case SyntaxKind.TryKeyword: return 3;
case SyntaxKind.TypeOfKeyword: return 6;
case SyntaxKind.VarKeyword: return 3;
case SyntaxKind.VoidKeyword: return 4;
case SyntaxKind.WhileKeyword: return 5;
case SyntaxKind.WithKeyword: return 4;
case SyntaxKind.ClassKeyword: return 5;
case SyntaxKind.ConstKeyword: return 5;
case SyntaxKind.EnumKeyword: return 4;
case SyntaxKind.ExportKeyword: return 6;
case SyntaxKind.ExtendsKeyword: return 7;
case SyntaxKind.ImportKeyword: return 6;
case SyntaxKind.SuperKeyword: return 5;
case SyntaxKind.ImplementsKeyword: return 10;
case SyntaxKind.InterfaceKeyword: return 9;
case SyntaxKind.LetKeyword: return 3;
case SyntaxKind.PackageKeyword: return 7;
case SyntaxKind.PrivateKeyword: return 7;
case SyntaxKind.ProtectedKeyword: return 9;
case SyntaxKind.PublicKeyword: return 6;
case SyntaxKind.StaticKeyword: return 6;
case SyntaxKind.YieldKeyword: return 5;
case SyntaxKind.AnyKeyword: return 3;
case SyntaxKind.BooleanKeyword: return 7;
case SyntaxKind.ConstructorKeyword: return 11;
case SyntaxKind.DeclareKeyword: return 7;
case SyntaxKind.GetKeyword: return 3;
case SyntaxKind.ModuleKeyword: return 6;
case SyntaxKind.RequireKeyword: return 7;
case SyntaxKind.NumberKeyword: return 6;
case SyntaxKind.SetKeyword: return 3;
case SyntaxKind.StringKeyword: return 6;
case SyntaxKind.OpenBraceToken: return 1;
case SyntaxKind.CloseBraceToken: return 1;
case SyntaxKind.OpenParenToken: return 1;
case SyntaxKind.CloseParenToken: return 1;
case SyntaxKind.OpenBracketToken: return 1;
case SyntaxKind.CloseBracketToken: return 1;
case SyntaxKind.DotToken: return 1;
case SyntaxKind.DotDotDotToken: return 3;
case SyntaxKind.SemicolonToken: return 1;
case SyntaxKind.CommaToken: return 1;
case SyntaxKind.LessThanToken: return 1;
case SyntaxKind.GreaterThanToken: return 1;
case SyntaxKind.LessThanEqualsToken: return 2;
case SyntaxKind.GreaterThanEqualsToken: return 2;
case SyntaxKind.EqualsEqualsToken: return 2;
case SyntaxKind.EqualsGreaterThanToken: return 2;
case SyntaxKind.ExclamationEqualsToken: return 2;
case SyntaxKind.EqualsEqualsEqualsToken: return 3;
case SyntaxKind.ExclamationEqualsEqualsToken: return 3;
case SyntaxKind.PlusToken: return 1;
case SyntaxKind.MinusToken: return 1;
case SyntaxKind.AsteriskToken: return 1;
case SyntaxKind.PercentToken: return 1;
case SyntaxKind.PlusPlusToken: return 2;
case SyntaxKind.MinusMinusToken: return 2;
case SyntaxKind.LessThanLessThanToken: return 2;
case SyntaxKind.GreaterThanGreaterThanToken: return 2;
case SyntaxKind.GreaterThanGreaterThanGreaterThanToken: return 3;
case SyntaxKind.AmpersandToken: return 1;
case SyntaxKind.BarToken: return 1;
case SyntaxKind.CaretToken: return 1;
case SyntaxKind.ExclamationToken: return 1;
case SyntaxKind.TildeToken: return 1;
case SyntaxKind.AmpersandAmpersandToken: return 2;
case SyntaxKind.BarBarToken: return 2;
case SyntaxKind.QuestionToken: return 1;
case SyntaxKind.ColonToken: return 1;
case SyntaxKind.EqualsToken: return 1;
case SyntaxKind.PlusEqualsToken: return 2;
case SyntaxKind.MinusEqualsToken: return 2;
case SyntaxKind.AsteriskEqualsToken: return 2;
case SyntaxKind.PercentEqualsToken: return 2;
case SyntaxKind.LessThanLessThanEqualsToken: return 3;
case SyntaxKind.GreaterThanGreaterThanEqualsToken: return 3;
case SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken: return 4;
case SyntaxKind.AmpersandEqualsToken: return 2;
case SyntaxKind.BarEqualsToken: return 2;
case SyntaxKind.CaretEqualsToken: return 2;
case SyntaxKind.SlashToken: return 1;
case SyntaxKind.SlashEqualsToken: return 2;
default: throw new Error();
}
return fixedWidthArray[kind];
}
}

View File

@ -2,117 +2,6 @@
module TypeScript {
export module ScannerUtilities {
export function fixedWidthTokenLength(kind: SyntaxKind) {
switch (kind) {
case SyntaxKind.BreakKeyword: return 5;
case SyntaxKind.CaseKeyword: return 4;
case SyntaxKind.CatchKeyword: return 5;
case SyntaxKind.ContinueKeyword: return 8;
case SyntaxKind.DebuggerKeyword: return 8;
case SyntaxKind.DefaultKeyword: return 7;
case SyntaxKind.DeleteKeyword: return 6;
case SyntaxKind.DoKeyword: return 2;
case SyntaxKind.ElseKeyword: return 4;
case SyntaxKind.FalseKeyword: return 5;
case SyntaxKind.FinallyKeyword: return 7;
case SyntaxKind.ForKeyword: return 3;
case SyntaxKind.FunctionKeyword: return 8;
case SyntaxKind.IfKeyword: return 2;
case SyntaxKind.InKeyword: return 2;
case SyntaxKind.InstanceOfKeyword: return 10;
case SyntaxKind.NewKeyword: return 3;
case SyntaxKind.NullKeyword: return 4;
case SyntaxKind.ReturnKeyword: return 6;
case SyntaxKind.SwitchKeyword: return 6;
case SyntaxKind.ThisKeyword: return 4;
case SyntaxKind.ThrowKeyword: return 5;
case SyntaxKind.TrueKeyword: return 4;
case SyntaxKind.TryKeyword: return 3;
case SyntaxKind.TypeOfKeyword: return 6;
case SyntaxKind.VarKeyword: return 3;
case SyntaxKind.VoidKeyword: return 4;
case SyntaxKind.WhileKeyword: return 5;
case SyntaxKind.WithKeyword: return 4;
case SyntaxKind.ClassKeyword: return 5;
case SyntaxKind.ConstKeyword: return 5;
case SyntaxKind.EnumKeyword: return 4;
case SyntaxKind.ExportKeyword: return 6;
case SyntaxKind.ExtendsKeyword: return 7;
case SyntaxKind.ImportKeyword: return 6;
case SyntaxKind.SuperKeyword: return 5;
case SyntaxKind.ImplementsKeyword: return 10;
case SyntaxKind.InterfaceKeyword: return 9;
case SyntaxKind.LetKeyword: return 3;
case SyntaxKind.PackageKeyword: return 7;
case SyntaxKind.PrivateKeyword: return 7;
case SyntaxKind.ProtectedKeyword: return 9;
case SyntaxKind.PublicKeyword: return 6;
case SyntaxKind.StaticKeyword: return 6;
case SyntaxKind.YieldKeyword: return 5;
case SyntaxKind.AnyKeyword: return 3;
case SyntaxKind.BooleanKeyword: return 7;
case SyntaxKind.ConstructorKeyword: return 11;
case SyntaxKind.DeclareKeyword: return 7;
case SyntaxKind.GetKeyword: return 3;
case SyntaxKind.ModuleKeyword: return 6;
case SyntaxKind.RequireKeyword: return 7;
case SyntaxKind.NumberKeyword: return 6;
case SyntaxKind.SetKeyword: return 3;
case SyntaxKind.StringKeyword: return 6;
case SyntaxKind.OpenBraceToken: return 1;
case SyntaxKind.CloseBraceToken: return 1;
case SyntaxKind.OpenParenToken: return 1;
case SyntaxKind.CloseParenToken: return 1;
case SyntaxKind.OpenBracketToken: return 1;
case SyntaxKind.CloseBracketToken: return 1;
case SyntaxKind.DotToken: return 1;
case SyntaxKind.DotDotDotToken: return 3;
case SyntaxKind.SemicolonToken: return 1;
case SyntaxKind.CommaToken: return 1;
case SyntaxKind.LessThanToken: return 1;
case SyntaxKind.GreaterThanToken: return 1;
case SyntaxKind.LessThanEqualsToken: return 2;
case SyntaxKind.GreaterThanEqualsToken: return 2;
case SyntaxKind.EqualsEqualsToken: return 2;
case SyntaxKind.EqualsGreaterThanToken: return 2;
case SyntaxKind.ExclamationEqualsToken: return 2;
case SyntaxKind.EqualsEqualsEqualsToken: return 3;
case SyntaxKind.ExclamationEqualsEqualsToken: return 3;
case SyntaxKind.PlusToken: return 1;
case SyntaxKind.MinusToken: return 1;
case SyntaxKind.AsteriskToken: return 1;
case SyntaxKind.PercentToken: return 1;
case SyntaxKind.PlusPlusToken: return 2;
case SyntaxKind.MinusMinusToken: return 2;
case SyntaxKind.LessThanLessThanToken: return 2;
case SyntaxKind.GreaterThanGreaterThanToken: return 2;
case SyntaxKind.GreaterThanGreaterThanGreaterThanToken: return 3;
case SyntaxKind.AmpersandToken: return 1;
case SyntaxKind.BarToken: return 1;
case SyntaxKind.CaretToken: return 1;
case SyntaxKind.ExclamationToken: return 1;
case SyntaxKind.TildeToken: return 1;
case SyntaxKind.AmpersandAmpersandToken: return 2;
case SyntaxKind.BarBarToken: return 2;
case SyntaxKind.QuestionToken: return 1;
case SyntaxKind.ColonToken: return 1;
case SyntaxKind.EqualsToken: return 1;
case SyntaxKind.PlusEqualsToken: return 2;
case SyntaxKind.MinusEqualsToken: return 2;
case SyntaxKind.AsteriskEqualsToken: return 2;
case SyntaxKind.PercentEqualsToken: return 2;
case SyntaxKind.LessThanLessThanEqualsToken: return 3;
case SyntaxKind.GreaterThanGreaterThanEqualsToken: return 3;
case SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken: return 4;
case SyntaxKind.AmpersandEqualsToken: return 2;
case SyntaxKind.BarEqualsToken: return 2;
case SyntaxKind.CaretEqualsToken: return 2;
case SyntaxKind.SlashToken: return 1;
case SyntaxKind.SlashEqualsToken: return 2;
default: throw new Error();
}
}
export function identifierKind(str: string, start: number, length: number): SyntaxKind {
switch (length) {
case 2: // do, if, in

View File

@ -9,7 +9,7 @@ module TypeScript.Syntax {
if (isToken(child)) {
var token = <ISyntaxToken>child;
// If a token is skipped, return true. Or if it is a missing token. The only empty token that is not missing is EOF
if (token.hasSkippedToken() || (width(token) === 0 && token.kind() !== SyntaxKind.EndOfFileToken)) {
if (token.hasSkippedToken() || (width(token) === 0 && token.kind !== SyntaxKind.EndOfFileToken)) {
return true;
}
}
@ -19,7 +19,7 @@ module TypeScript.Syntax {
}
export function isUnterminatedStringLiteral(token: ISyntaxToken): boolean {
if (token && token.kind() === SyntaxKind.StringLiteral) {
if (token && token.kind === SyntaxKind.StringLiteral) {
var text = token.text();
return text.length < 2 || text.charCodeAt(text.length - 1) !== text.charCodeAt(0);
}
@ -55,7 +55,7 @@ module TypeScript.Syntax {
var triviaList: ISyntaxTriviaList = undefined;
var lastTriviaBeforeToken: ISyntaxTrivia = undefined;
if (positionedToken.kind() === SyntaxKind.EndOfFileToken) {
if (positionedToken.kind === SyntaxKind.EndOfFileToken) {
// Check if the trivia is leading on the EndOfFile token
if (positionedToken.hasLeadingTrivia()) {
triviaList = positionedToken.leadingTrivia();
@ -106,14 +106,14 @@ module TypeScript.Syntax {
var positionedToken = findToken(sourceUnit, position);
if (positionedToken) {
if (positionedToken.kind() === SyntaxKind.EndOfFileToken) {
if (positionedToken.kind === SyntaxKind.EndOfFileToken) {
// EndOfFile token, enusre it did not follow an unterminated string literal
positionedToken = previousToken(positionedToken);
return positionedToken && positionedToken.trailingTriviaWidth() === 0 && isUnterminatedStringLiteral(positionedToken);
}
else if (position > start(positionedToken)) {
// Ensure position falls enterily within the literal if it is terminated, or the line if it is not
return (position < end(positionedToken) && (positionedToken.kind() === TypeScript.SyntaxKind.StringLiteral || positionedToken.kind() === TypeScript.SyntaxKind.RegularExpressionLiteral)) ||
return (position < end(positionedToken) && (positionedToken.kind === TypeScript.SyntaxKind.StringLiteral || positionedToken.kind === TypeScript.SyntaxKind.RegularExpressionLiteral)) ||
(position <= end(positionedToken) && isUnterminatedStringLiteral(positionedToken));
}
}
@ -123,7 +123,7 @@ module TypeScript.Syntax {
export function getAncestorOfKind(positionedToken: ISyntaxElement, kind: SyntaxKind): ISyntaxElement {
while (positionedToken && positionedToken.parent) {
if (positionedToken.parent.kind() === kind) {
if (positionedToken.parent.kind === kind) {
return positionedToken.parent;
}
@ -139,10 +139,10 @@ module TypeScript.Syntax {
export function isIntegerLiteral(expression: IExpressionSyntax): boolean {
if (expression) {
switch (expression.kind()) {
switch (expression.kind) {
case SyntaxKind.PrefixUnaryExpression:
var prefixExpr = <PrefixUnaryExpressionSyntax>expression;
if (prefixExpr.operatorToken.kind() == SyntaxKind.PlusToken || prefixExpr.operatorToken.kind() === SyntaxKind.MinusToken) {
if (prefixExpr.operatorToken.kind == SyntaxKind.PlusToken || prefixExpr.operatorToken.kind === SyntaxKind.MinusToken) {
// Note: if there is a + or - sign, we can only allow a normal integer following
// (and not a hex integer). i.e. -0xA is a legal expression, but it is not a
// *literal*.

View File

@ -6,7 +6,7 @@ module TypeScript {
// Debug.assert(!isShared(element));
while (element) {
if (element.kind() === SyntaxKind.SourceUnit) {
if (element.kind === SyntaxKind.SourceUnit) {
return (<SourceUnitSyntax>element).syntaxTree;
}
@ -53,7 +53,7 @@ module TypeScript {
throw Errors.argumentOutOfRange("position");
}
var token = findTokenWorker(sourceUnit, 0, position);
var token = findTokenInNodeOrToken(sourceUnit, 0, position);
if (token) {
Debug.assert(token.fullWidth() > 0);
return token;
@ -113,13 +113,40 @@ module TypeScript {
}
function findTokenWorker(element: ISyntaxElement, elementPosition: number, position: number): ISyntaxToken {
if (isToken(element)) {
return <ISyntaxToken>element;
if (isList(element)) {
return findTokenInList(<ISyntaxNodeOrToken[]>element, elementPosition, position);
}
else {
return findTokenInNodeOrToken(<ISyntaxNodeOrToken>element, elementPosition, position);
}
}
function findTokenInList(list: ISyntaxNodeOrToken[], elementPosition: number, position: number): ISyntaxToken {
for (var i = 0, n = list.length; i < n; i++) {
var child = list[i];
var childFullWidth = fullWidth(child);
var elementEndPosition = elementPosition + childFullWidth;
if (position < elementEndPosition) {
return findTokenWorker(child, elementPosition, position);
}
elementPosition = elementEndPosition;
}
// Consider: we could use a binary search here to find the child more quickly.
for (var i = 0, n = childCount(element); i < n; i++) {
var child = childAt(element, i);
return undefined;
}
function findTokenInNodeOrToken(nodeOrToken: ISyntaxNodeOrToken, elementPosition: number, position: number): ISyntaxToken {
if (isToken(nodeOrToken)) {
return <ISyntaxToken>nodeOrToken;
}
var childAtFunction = getChildAtFunction(nodeOrToken);
for (var i = 0, n = childCount(nodeOrToken); i < n; i++) {
var child = childAtFunction(nodeOrToken, i);
if (child) {
var childFullWidth = fullWidth(child);
@ -137,7 +164,7 @@ module TypeScript {
}
function tryGetEndOfFileAt(element: ISyntaxElement, position: number): ISyntaxToken {
if (element.kind() === SyntaxKind.SourceUnit && position === fullWidth(element)) {
if (element.kind === SyntaxKind.SourceUnit && position === fullWidth(element)) {
var sourceUnit = <SourceUnitSyntax>element;
return sourceUnit.endOfFileToken;
}
@ -146,7 +173,7 @@ module TypeScript {
}
export function nextToken(token: ISyntaxToken, text?: ISimpleText): ISyntaxToken {
if (token.kind() === SyntaxKind.EndOfFileToken) {
if (token.kind === SyntaxKind.EndOfFileToken) {
return undefined;
}
@ -155,7 +182,7 @@ module TypeScript {
export function isNode(element: ISyntaxElement): boolean {
if (element) {
var kind = element.kind();
var kind = element.kind;
return kind >= SyntaxKind.FirstNode && kind <= SyntaxKind.LastNode;
}
@ -168,7 +195,7 @@ module TypeScript {
export function isToken(element: ISyntaxElement): boolean {
if (element) {
return isTokenKind(element.kind());
return isTokenKind(element.kind);
}
return false;
@ -227,7 +254,7 @@ module TypeScript {
export function firstToken(element: ISyntaxElement): ISyntaxToken {
if (element) {
var kind = element.kind();
var kind = element.kind;
if (isTokenKind(kind)) {
return (<ISyntaxToken>element).fullWidth() > 0 || kind === SyntaxKind.EndOfFileToken ? <ISyntaxToken>element : undefined;
@ -246,10 +273,10 @@ module TypeScript {
export function lastToken(element: ISyntaxElement): ISyntaxToken {
if (isToken(element)) {
return fullWidth(element) > 0 || element.kind() === SyntaxKind.EndOfFileToken ? <ISyntaxToken>element : undefined;
return fullWidth(element) > 0 || element.kind === SyntaxKind.EndOfFileToken ? <ISyntaxToken>element : undefined;
}
if (element.kind() === SyntaxKind.SourceUnit) {
if (element.kind === SyntaxKind.SourceUnit) {
return (<SourceUnitSyntax>element).endOfFileToken;
}
@ -366,7 +393,7 @@ module TypeScript {
}
export interface ISyntaxElement {
kind(): SyntaxKind;
kind: SyntaxKind;
parent: ISyntaxElement;
}

View File

@ -2,16 +2,8 @@
module TypeScript.SyntaxFacts {
export function isDirectivePrologueElement(node: ISyntaxNodeOrToken): boolean {
if (node.kind() === SyntaxKind.ExpressionStatement) {
var expressionStatement = <ExpressionStatementSyntax>node;
var expression = expressionStatement.expression;
if (expression.kind() === SyntaxKind.StringLiteral) {
return true;
}
}
return false;
return node.kind === SyntaxKind.ExpressionStatement &&
(<ExpressionStatementSyntax>node).expression.kind === SyntaxKind.StringLiteral;
}
export function isUseStrictDirective(node: ISyntaxNodeOrToken): boolean {
@ -23,7 +15,7 @@ module TypeScript.SyntaxFacts {
}
export function isIdentifierNameOrAnyKeyword(token: ISyntaxToken): boolean {
var tokenKind = token.kind();
var tokenKind = token.kind;
return tokenKind === SyntaxKind.IdentifierName || SyntaxFacts.isAnyKeyword(tokenKind);
}

View File

@ -1153,7 +1153,7 @@ function generateConstructorFunction(definition: ITypeDefinition) {
}
result += " };\r\n";
result += " " + definition.name + ".prototype.kind = function() { return SyntaxKind." + getNameWithoutSuffix(definition) + "; }\r\n";
result += " " + definition.name + ".prototype.kind = SyntaxKind." + getNameWithoutSuffix(definition) + ";\r\n";
return result;
}
@ -1401,22 +1401,44 @@ function max<T>(array: T[], func: (v: T) => number): number {
return max;
}
function generateUtilities(): string {
var result = "";
result += " var fixedWidthArray = [";
for (var i = 0; i <= TypeScript.SyntaxKind.LastFixedWidth; i++) {
if (i) {
result += ", ";
}
if (i < TypeScript.SyntaxKind.FirstFixedWidth) {
result += "0";
}
else {
result += TypeScript.SyntaxFacts.getText(i).length;
}
}
result += "];\r\n";
result += " function fixedWidthTokenLength(kind: SyntaxKind) {\r\n";
result += " return fixedWidthArray[kind];\r\n";
//result += " switch (kind) {\r\n";
//for (var k = TypeScript.SyntaxKind.FirstFixedWidth; k <= TypeScript.SyntaxKind.LastFixedWidth; k++) {
// result += " case SyntaxKind." + syntaxKindName(k) + ": return " + TypeScript.SyntaxFacts.getText(k).length + ";\r\n";
//}
//result += " default: throw new Error();\r\n";
//result += " }\r\n";
result += " }\r\n";
return result;
}
function generateScannerUtilities(): string {
var result = "///<reference path='references.ts' />\r\n" +
"\r\n" +
"module TypeScript {\r\n" +
" export module ScannerUtilities {\r\n";
result += " export function fixedWidthTokenLength(kind: SyntaxKind) {\r\n";
result += " switch (kind) {\r\n";
for (var k = TypeScript.SyntaxKind.FirstFixedWidth; k <= TypeScript.SyntaxKind.LastFixedWidth; k++) {
result += " case SyntaxKind." + syntaxKindName(k) + ": return " + TypeScript.SyntaxFacts.getText(k).length + ";\r\n";
}
result += " default: throw new Error();\r\n";
result += " }\r\n";
result += " }\r\n\r\n";
var i: number;
var keywords: { text: string; kind: TypeScript.SyntaxKind; }[] = [];
@ -1470,7 +1492,7 @@ function generateVisitor(): string {
result += " export function visitNodeOrToken(visitor: ISyntaxVisitor, element: ISyntaxNodeOrToken): any {\r\n";
result += " if (element === undefined) { return undefined; }\r\n";
result += " switch (element.kind()) {\r\n";
result += " switch (element.kind) {\r\n";
for (var i = 0; i < definitions.length; i++) {
var definition = definitions[i];
@ -1512,7 +1534,7 @@ function generateServicesUtilities(): string {
result += "0";
}
else {
var definition = TypeScript.ArrayUtilities.first(definitions,d => firstKind(d) === i);
var definition = TypeScript.ArrayUtilities.first(definitions, d => firstKind(d) === i);
result += definition.children.length;
}
}
@ -1520,40 +1542,80 @@ function generateServicesUtilities(): string {
result += " export function childCount(element: ISyntaxElement): number {\r\n";
result += " if (isList(element)) { return (<ISyntaxNodeOrToken[]>element).length; }\r\n";
result += " return childCountArray[element.kind()];\r\n";
result += " return childCountArray[element.kind];\r\n";
result += " }\r\n\r\n";
result += " var childAtArray: ((nodeOrToken: ISyntaxElement, index: number) => ISyntaxElement)[] = [\r\n ";
for (var i = 0; i < TypeScript.SyntaxKind.FirstNode; i++) {
if (i) {
result += ", ";
}
result += "undefined";
}
for (var i = 0; i < definitions.length; i++) {
var definition = definitions[i];
result += " function " + camelCase(getNameWithoutSuffix(definition)) + "ChildAt(node: " + definition.name + ", index: number): ISyntaxElement {\r\n";
result += ",\r\n"
result += " (node: " + definition.name + ", index: number): ISyntaxElement => {\r\n";
if (definition.children.length) {
result += " switch (index) {\r\n";
result += " switch (index) {\r\n";
for (var j = 0; j < definition.children.length; j++) {
result += " case " + j + ": return node." + definition.children[j].name + ";\r\n";
result += " case " + j + ": return node." + definition.children[j].name + ";\r\n";
}
result += " }\r\n";
result += " }\r\n";
}
else {
result += " throw Errors.invalidOperation();\r\n";
result += " throw Errors.invalidOperation();\r\n";
}
result += " }\r\n";
result += " }";
}
result += "\r\n ];\r\n";
//for (var i = 0; i < definitions.length; i++) {
// var definition = definitions[i];
// result += " function " + camelCase(getNameWithoutSuffix(definition)) + "ChildAt(node: " + definition.name + ", index: number): ISyntaxElement {\r\n";
// if (definition.children.length) {
// result += " switch (index) {\r\n";
// for (var j = 0; j < definition.children.length; j++) {
// result += " case " + j + ": return node." + definition.children[j].name + ";\r\n";
// }
// result += " }\r\n";
// }
// else {
// result += " throw Errors.invalidOperation();\r\n";
// }
// result += " }\r\n";
//}
result += " export function childAt(element: ISyntaxElement, index: number): ISyntaxElement {\r\n";
result += " if (isList(element)) { return (<ISyntaxNodeOrToken[]>element)[index]; }\r\n";
result += " switch (element.kind()) {\r\n";
result += " return childAtArray[element.kind](element, index);\r\n";
//result += " switch (element.kind) {\r\n";
for (var i = 0; i < definitions.length; i++) {
var definition = definitions[i];
result += " case SyntaxKind." + getNameWithoutSuffix(definition) + ": return " + camelCase(getNameWithoutSuffix(definition)) + "ChildAt(<" + definition.name + ">element, index);\r\n";
}
//for (var i = 0; i < definitions.length; i++) {
// var definition = definitions[i];
// result += " case SyntaxKind." + getNameWithoutSuffix(definition) + ": return " + camelCase(getNameWithoutSuffix(definition)) + "ChildAt(<" + definition.name + ">element, index);\r\n";
//}
result += " }\r\n";
//result += " }\r\n";
result += " }\r\n\r\n";
result += " export function getChildAtFunction(element: ISyntaxNodeOrToken): (nodeOrToken: ISyntaxElement, index: number) => ISyntaxElement {\r\n";
result += " return childAtArray[element.kind];\r\n";
result += " }\r\n";
result += "}";
@ -1566,6 +1628,7 @@ var walker = generateWalker();
var scannerUtilities = generateScannerUtilities();
var visitor = generateVisitor();
var servicesUtilities = generateServicesUtilities();
var utilities = generateUtilities();
sys.writeFile(sys.getCurrentDirectory() + "\\src\\services\\syntax\\syntaxNodes.concrete.generated.ts", syntaxNodesConcrete, false);
sys.writeFile(sys.getCurrentDirectory() + "\\src\\services\\syntax\\syntaxInterfaces.generated.ts", syntaxInterfaces, false);
@ -1573,3 +1636,4 @@ sys.writeFile(sys.getCurrentDirectory() + "\\src\\services\\syntax\\syntaxWalker
sys.writeFile(sys.getCurrentDirectory() + "\\src\\services\\syntax\\scannerUtilities.generated.ts", scannerUtilities, false);
sys.writeFile(sys.getCurrentDirectory() + "\\src\\services\\syntax\\syntaxVisitor.generated.ts", visitor, false);
sys.writeFile(sys.getCurrentDirectory() + "\\src\\services\\syntax\\syntaxUtilities.generated.ts", servicesUtilities, false);
sys.writeFile(sys.getCurrentDirectory() + "\\src\\services\\syntax\\utilities.generated.ts", utilities, false);

View File

@ -3,7 +3,7 @@
interface Array<T> {
__data: number;
kind(): TypeScript.SyntaxKind;
kind: TypeScript.SyntaxKind;
parent: TypeScript.ISyntaxElement;
}
@ -36,18 +36,16 @@ module TypeScript {
}
module TypeScript.Syntax {
function addArrayFunction(name: string, func: Function) {
if (Object.defineProperty) {
Object.defineProperty(Array.prototype, name, { value: func, writable: true });
function addArrayPrototypeValue(name: string, val: any) {
if (Object.defineProperty && (<any>Array.prototype)[name] === undefined) {
Object.defineProperty(Array.prototype, name, { value: val, writable: false });
}
else {
(<any>Array.prototype)[name] = func;
(<any>Array.prototype)[name] = val;
}
}
addArrayFunction("kind", function () {
return SyntaxKind.List;
});
addArrayPrototypeValue("kind", SyntaxKind.List);
export function list<T extends ISyntaxNodeOrToken>(nodes: T[]): T[] {
for (var i = 0, n = nodes.length; i < n; i++) {

View File

@ -6,633 +6,633 @@ module TypeScript {
this.moduleElements = moduleElements, this.endOfFileToken = endOfFileToken;
moduleElements.parent = this, endOfFileToken.parent = this;
};
SourceUnitSyntax.prototype.kind = function() { return SyntaxKind.SourceUnit; }
SourceUnitSyntax.prototype.kind = SyntaxKind.SourceUnit;
export var QualifiedNameSyntax: QualifiedNameConstructor = <any>function(data: number, left: INameSyntax, dotToken: ISyntaxToken, right: ISyntaxToken) {
if (data) { this.__data = data; }
this.left = left, this.dotToken = dotToken, this.right = right;
left.parent = this, dotToken.parent = this, right.parent = this;
};
QualifiedNameSyntax.prototype.kind = function() { return SyntaxKind.QualifiedName; }
QualifiedNameSyntax.prototype.kind = SyntaxKind.QualifiedName;
export var ObjectTypeSyntax: ObjectTypeConstructor = <any>function(data: number, openBraceToken: ISyntaxToken, typeMembers: ISeparatedSyntaxList<ITypeMemberSyntax>, closeBraceToken: ISyntaxToken) {
if (data) { this.__data = data; }
this.openBraceToken = openBraceToken, this.typeMembers = typeMembers, this.closeBraceToken = closeBraceToken;
openBraceToken.parent = this, typeMembers.parent = this, closeBraceToken.parent = this;
};
ObjectTypeSyntax.prototype.kind = function() { return SyntaxKind.ObjectType; }
ObjectTypeSyntax.prototype.kind = SyntaxKind.ObjectType;
export var FunctionTypeSyntax: FunctionTypeConstructor = <any>function(data: number, typeParameterList: TypeParameterListSyntax, parameterList: ParameterListSyntax, equalsGreaterThanToken: ISyntaxToken, type: ITypeSyntax) {
if (data) { this.__data = data; }
this.typeParameterList = typeParameterList, this.parameterList = parameterList, this.equalsGreaterThanToken = equalsGreaterThanToken, this.type = type;
typeParameterList && (typeParameterList.parent = this), parameterList.parent = this, equalsGreaterThanToken.parent = this, type.parent = this;
};
FunctionTypeSyntax.prototype.kind = function() { return SyntaxKind.FunctionType; }
FunctionTypeSyntax.prototype.kind = SyntaxKind.FunctionType;
export var ArrayTypeSyntax: ArrayTypeConstructor = <any>function(data: number, type: ITypeSyntax, openBracketToken: ISyntaxToken, closeBracketToken: ISyntaxToken) {
if (data) { this.__data = data; }
this.type = type, this.openBracketToken = openBracketToken, this.closeBracketToken = closeBracketToken;
type.parent = this, openBracketToken.parent = this, closeBracketToken.parent = this;
};
ArrayTypeSyntax.prototype.kind = function() { return SyntaxKind.ArrayType; }
ArrayTypeSyntax.prototype.kind = SyntaxKind.ArrayType;
export var ConstructorTypeSyntax: ConstructorTypeConstructor = <any>function(data: number, newKeyword: ISyntaxToken, typeParameterList: TypeParameterListSyntax, parameterList: ParameterListSyntax, equalsGreaterThanToken: ISyntaxToken, type: ITypeSyntax) {
if (data) { this.__data = data; }
this.newKeyword = newKeyword, this.typeParameterList = typeParameterList, this.parameterList = parameterList, this.equalsGreaterThanToken = equalsGreaterThanToken, this.type = type;
newKeyword.parent = this, typeParameterList && (typeParameterList.parent = this), parameterList.parent = this, equalsGreaterThanToken.parent = this, type.parent = this;
};
ConstructorTypeSyntax.prototype.kind = function() { return SyntaxKind.ConstructorType; }
ConstructorTypeSyntax.prototype.kind = SyntaxKind.ConstructorType;
export var GenericTypeSyntax: GenericTypeConstructor = <any>function(data: number, name: INameSyntax, typeArgumentList: TypeArgumentListSyntax) {
if (data) { this.__data = data; }
this.name = name, this.typeArgumentList = typeArgumentList;
name.parent = this, typeArgumentList.parent = this;
};
GenericTypeSyntax.prototype.kind = function() { return SyntaxKind.GenericType; }
GenericTypeSyntax.prototype.kind = SyntaxKind.GenericType;
export var TypeQuerySyntax: TypeQueryConstructor = <any>function(data: number, typeOfKeyword: ISyntaxToken, name: INameSyntax) {
if (data) { this.__data = data; }
this.typeOfKeyword = typeOfKeyword, this.name = name;
typeOfKeyword.parent = this, name.parent = this;
};
TypeQuerySyntax.prototype.kind = function() { return SyntaxKind.TypeQuery; }
TypeQuerySyntax.prototype.kind = SyntaxKind.TypeQuery;
export var TupleTypeSyntax: TupleTypeConstructor = <any>function(data: number, openBracketToken: ISyntaxToken, types: ISeparatedSyntaxList<ITypeSyntax>, closeBracketToken: ISyntaxToken) {
if (data) { this.__data = data; }
this.openBracketToken = openBracketToken, this.types = types, this.closeBracketToken = closeBracketToken;
openBracketToken.parent = this, types.parent = this, closeBracketToken.parent = this;
};
TupleTypeSyntax.prototype.kind = function() { return SyntaxKind.TupleType; }
TupleTypeSyntax.prototype.kind = SyntaxKind.TupleType;
export var UnionTypeSyntax: UnionTypeConstructor = <any>function(data: number, left: ITypeSyntax, barToken: ISyntaxToken, right: ITypeSyntax) {
if (data) { this.__data = data; }
this.left = left, this.barToken = barToken, this.right = right;
left.parent = this, barToken.parent = this, right.parent = this;
};
UnionTypeSyntax.prototype.kind = function() { return SyntaxKind.UnionType; }
UnionTypeSyntax.prototype.kind = SyntaxKind.UnionType;
export var ParenthesizedTypeSyntax: ParenthesizedTypeConstructor = <any>function(data: number, openParenToken: ISyntaxToken, type: ITypeSyntax, closeParenToken: ISyntaxToken) {
if (data) { this.__data = data; }
this.openParenToken = openParenToken, this.type = type, this.closeParenToken = closeParenToken;
openParenToken.parent = this, type.parent = this, closeParenToken.parent = this;
};
ParenthesizedTypeSyntax.prototype.kind = function() { return SyntaxKind.ParenthesizedType; }
ParenthesizedTypeSyntax.prototype.kind = SyntaxKind.ParenthesizedType;
export var InterfaceDeclarationSyntax: InterfaceDeclarationConstructor = <any>function(data: number, modifiers: ISyntaxToken[], interfaceKeyword: ISyntaxToken, identifier: ISyntaxToken, typeParameterList: TypeParameterListSyntax, heritageClauses: HeritageClauseSyntax[], body: ObjectTypeSyntax) {
if (data) { this.__data = data; }
this.modifiers = modifiers, this.interfaceKeyword = interfaceKeyword, this.identifier = identifier, this.typeParameterList = typeParameterList, this.heritageClauses = heritageClauses, this.body = body;
modifiers.parent = this, interfaceKeyword.parent = this, identifier.parent = this, typeParameterList && (typeParameterList.parent = this), heritageClauses.parent = this, body.parent = this;
};
InterfaceDeclarationSyntax.prototype.kind = function() { return SyntaxKind.InterfaceDeclaration; }
InterfaceDeclarationSyntax.prototype.kind = SyntaxKind.InterfaceDeclaration;
export var FunctionDeclarationSyntax: FunctionDeclarationConstructor = <any>function(data: number, modifiers: ISyntaxToken[], functionKeyword: ISyntaxToken, identifier: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax, semicolonToken: ISyntaxToken) {
if (data) { this.__data = data; }
this.modifiers = modifiers, this.functionKeyword = functionKeyword, this.identifier = identifier, this.callSignature = callSignature, this.block = block, this.semicolonToken = semicolonToken;
modifiers.parent = this, functionKeyword.parent = this, identifier.parent = this, callSignature.parent = this, block && (block.parent = this), semicolonToken && (semicolonToken.parent = this);
};
FunctionDeclarationSyntax.prototype.kind = function() { return SyntaxKind.FunctionDeclaration; }
FunctionDeclarationSyntax.prototype.kind = SyntaxKind.FunctionDeclaration;
export var ModuleDeclarationSyntax: ModuleDeclarationConstructor = <any>function(data: number, modifiers: ISyntaxToken[], moduleKeyword: ISyntaxToken, name: INameSyntax, stringLiteral: ISyntaxToken, openBraceToken: ISyntaxToken, moduleElements: IModuleElementSyntax[], closeBraceToken: ISyntaxToken) {
if (data) { this.__data = data; }
this.modifiers = modifiers, this.moduleKeyword = moduleKeyword, this.name = name, this.stringLiteral = stringLiteral, this.openBraceToken = openBraceToken, this.moduleElements = moduleElements, this.closeBraceToken = closeBraceToken;
modifiers.parent = this, moduleKeyword.parent = this, name && (name.parent = this), stringLiteral && (stringLiteral.parent = this), openBraceToken.parent = this, moduleElements.parent = this, closeBraceToken.parent = this;
};
ModuleDeclarationSyntax.prototype.kind = function() { return SyntaxKind.ModuleDeclaration; }
ModuleDeclarationSyntax.prototype.kind = SyntaxKind.ModuleDeclaration;
export var ClassDeclarationSyntax: ClassDeclarationConstructor = <any>function(data: number, modifiers: ISyntaxToken[], classKeyword: ISyntaxToken, identifier: ISyntaxToken, typeParameterList: TypeParameterListSyntax, heritageClauses: HeritageClauseSyntax[], openBraceToken: ISyntaxToken, classElements: IClassElementSyntax[], closeBraceToken: ISyntaxToken) {
if (data) { this.__data = data; }
this.modifiers = modifiers, this.classKeyword = classKeyword, this.identifier = identifier, this.typeParameterList = typeParameterList, this.heritageClauses = heritageClauses, this.openBraceToken = openBraceToken, this.classElements = classElements, this.closeBraceToken = closeBraceToken;
modifiers.parent = this, classKeyword.parent = this, identifier.parent = this, typeParameterList && (typeParameterList.parent = this), heritageClauses.parent = this, openBraceToken.parent = this, classElements.parent = this, closeBraceToken.parent = this;
};
ClassDeclarationSyntax.prototype.kind = function() { return SyntaxKind.ClassDeclaration; }
ClassDeclarationSyntax.prototype.kind = SyntaxKind.ClassDeclaration;
export var EnumDeclarationSyntax: EnumDeclarationConstructor = <any>function(data: number, modifiers: ISyntaxToken[], enumKeyword: ISyntaxToken, identifier: ISyntaxToken, openBraceToken: ISyntaxToken, enumElements: ISeparatedSyntaxList<EnumElementSyntax>, closeBraceToken: ISyntaxToken) {
if (data) { this.__data = data; }
this.modifiers = modifiers, this.enumKeyword = enumKeyword, this.identifier = identifier, this.openBraceToken = openBraceToken, this.enumElements = enumElements, this.closeBraceToken = closeBraceToken;
modifiers.parent = this, enumKeyword.parent = this, identifier.parent = this, openBraceToken.parent = this, enumElements.parent = this, closeBraceToken.parent = this;
};
EnumDeclarationSyntax.prototype.kind = function() { return SyntaxKind.EnumDeclaration; }
EnumDeclarationSyntax.prototype.kind = SyntaxKind.EnumDeclaration;
export var ImportDeclarationSyntax: ImportDeclarationConstructor = <any>function(data: number, modifiers: ISyntaxToken[], importKeyword: ISyntaxToken, identifier: ISyntaxToken, equalsToken: ISyntaxToken, moduleReference: IModuleReferenceSyntax, semicolonToken: ISyntaxToken) {
if (data) { this.__data = data; }
this.modifiers = modifiers, this.importKeyword = importKeyword, this.identifier = identifier, this.equalsToken = equalsToken, this.moduleReference = moduleReference, this.semicolonToken = semicolonToken;
modifiers.parent = this, importKeyword.parent = this, identifier.parent = this, equalsToken.parent = this, moduleReference.parent = this, semicolonToken && (semicolonToken.parent = this);
};
ImportDeclarationSyntax.prototype.kind = function() { return SyntaxKind.ImportDeclaration; }
ImportDeclarationSyntax.prototype.kind = SyntaxKind.ImportDeclaration;
export var ExportAssignmentSyntax: ExportAssignmentConstructor = <any>function(data: number, exportKeyword: ISyntaxToken, equalsToken: ISyntaxToken, identifier: ISyntaxToken, semicolonToken: ISyntaxToken) {
if (data) { this.__data = data; }
this.exportKeyword = exportKeyword, this.equalsToken = equalsToken, this.identifier = identifier, this.semicolonToken = semicolonToken;
exportKeyword.parent = this, equalsToken.parent = this, identifier.parent = this, semicolonToken && (semicolonToken.parent = this);
};
ExportAssignmentSyntax.prototype.kind = function() { return SyntaxKind.ExportAssignment; }
ExportAssignmentSyntax.prototype.kind = SyntaxKind.ExportAssignment;
export var MemberFunctionDeclarationSyntax: MemberFunctionDeclarationConstructor = <any>function(data: number, modifiers: ISyntaxToken[], propertyName: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax, semicolonToken: ISyntaxToken) {
if (data) { this.__data = data; }
this.modifiers = modifiers, this.propertyName = propertyName, this.callSignature = callSignature, this.block = block, this.semicolonToken = semicolonToken;
modifiers.parent = this, propertyName.parent = this, callSignature.parent = this, block && (block.parent = this), semicolonToken && (semicolonToken.parent = this);
};
MemberFunctionDeclarationSyntax.prototype.kind = function() { return SyntaxKind.MemberFunctionDeclaration; }
MemberFunctionDeclarationSyntax.prototype.kind = SyntaxKind.MemberFunctionDeclaration;
export var MemberVariableDeclarationSyntax: MemberVariableDeclarationConstructor = <any>function(data: number, modifiers: ISyntaxToken[], variableDeclarator: VariableDeclaratorSyntax, semicolonToken: ISyntaxToken) {
if (data) { this.__data = data; }
this.modifiers = modifiers, this.variableDeclarator = variableDeclarator, this.semicolonToken = semicolonToken;
modifiers.parent = this, variableDeclarator.parent = this, semicolonToken && (semicolonToken.parent = this);
};
MemberVariableDeclarationSyntax.prototype.kind = function() { return SyntaxKind.MemberVariableDeclaration; }
MemberVariableDeclarationSyntax.prototype.kind = SyntaxKind.MemberVariableDeclaration;
export var ConstructorDeclarationSyntax: ConstructorDeclarationConstructor = <any>function(data: number, modifiers: ISyntaxToken[], constructorKeyword: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax, semicolonToken: ISyntaxToken) {
if (data) { this.__data = data; }
this.modifiers = modifiers, this.constructorKeyword = constructorKeyword, this.callSignature = callSignature, this.block = block, this.semicolonToken = semicolonToken;
modifiers.parent = this, constructorKeyword.parent = this, callSignature.parent = this, block && (block.parent = this), semicolonToken && (semicolonToken.parent = this);
};
ConstructorDeclarationSyntax.prototype.kind = function() { return SyntaxKind.ConstructorDeclaration; }
ConstructorDeclarationSyntax.prototype.kind = SyntaxKind.ConstructorDeclaration;
export var IndexMemberDeclarationSyntax: IndexMemberDeclarationConstructor = <any>function(data: number, modifiers: ISyntaxToken[], indexSignature: IndexSignatureSyntax, semicolonToken: ISyntaxToken) {
if (data) { this.__data = data; }
this.modifiers = modifiers, this.indexSignature = indexSignature, this.semicolonToken = semicolonToken;
modifiers.parent = this, indexSignature.parent = this, semicolonToken && (semicolonToken.parent = this);
};
IndexMemberDeclarationSyntax.prototype.kind = function() { return SyntaxKind.IndexMemberDeclaration; }
IndexMemberDeclarationSyntax.prototype.kind = SyntaxKind.IndexMemberDeclaration;
export var GetAccessorSyntax: GetAccessorConstructor = <any>function(data: number, modifiers: ISyntaxToken[], getKeyword: ISyntaxToken, propertyName: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax) {
if (data) { this.__data = data; }
this.modifiers = modifiers, this.getKeyword = getKeyword, this.propertyName = propertyName, this.callSignature = callSignature, this.block = block;
modifiers.parent = this, getKeyword.parent = this, propertyName.parent = this, callSignature.parent = this, block.parent = this;
};
GetAccessorSyntax.prototype.kind = function() { return SyntaxKind.GetAccessor; }
GetAccessorSyntax.prototype.kind = SyntaxKind.GetAccessor;
export var SetAccessorSyntax: SetAccessorConstructor = <any>function(data: number, modifiers: ISyntaxToken[], setKeyword: ISyntaxToken, propertyName: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax) {
if (data) { this.__data = data; }
this.modifiers = modifiers, this.setKeyword = setKeyword, this.propertyName = propertyName, this.callSignature = callSignature, this.block = block;
modifiers.parent = this, setKeyword.parent = this, propertyName.parent = this, callSignature.parent = this, block.parent = this;
};
SetAccessorSyntax.prototype.kind = function() { return SyntaxKind.SetAccessor; }
SetAccessorSyntax.prototype.kind = SyntaxKind.SetAccessor;
export var PropertySignatureSyntax: PropertySignatureConstructor = <any>function(data: number, propertyName: ISyntaxToken, questionToken: ISyntaxToken, typeAnnotation: TypeAnnotationSyntax) {
if (data) { this.__data = data; }
this.propertyName = propertyName, this.questionToken = questionToken, this.typeAnnotation = typeAnnotation;
propertyName.parent = this, questionToken && (questionToken.parent = this), typeAnnotation && (typeAnnotation.parent = this);
};
PropertySignatureSyntax.prototype.kind = function() { return SyntaxKind.PropertySignature; }
PropertySignatureSyntax.prototype.kind = SyntaxKind.PropertySignature;
export var CallSignatureSyntax: CallSignatureConstructor = <any>function(data: number, typeParameterList: TypeParameterListSyntax, parameterList: ParameterListSyntax, typeAnnotation: TypeAnnotationSyntax) {
if (data) { this.__data = data; }
this.typeParameterList = typeParameterList, this.parameterList = parameterList, this.typeAnnotation = typeAnnotation;
typeParameterList && (typeParameterList.parent = this), parameterList.parent = this, typeAnnotation && (typeAnnotation.parent = this);
};
CallSignatureSyntax.prototype.kind = function() { return SyntaxKind.CallSignature; }
CallSignatureSyntax.prototype.kind = SyntaxKind.CallSignature;
export var ConstructSignatureSyntax: ConstructSignatureConstructor = <any>function(data: number, newKeyword: ISyntaxToken, callSignature: CallSignatureSyntax) {
if (data) { this.__data = data; }
this.newKeyword = newKeyword, this.callSignature = callSignature;
newKeyword.parent = this, callSignature.parent = this;
};
ConstructSignatureSyntax.prototype.kind = function() { return SyntaxKind.ConstructSignature; }
ConstructSignatureSyntax.prototype.kind = SyntaxKind.ConstructSignature;
export var IndexSignatureSyntax: IndexSignatureConstructor = <any>function(data: number, openBracketToken: ISyntaxToken, parameters: ISeparatedSyntaxList<ParameterSyntax>, closeBracketToken: ISyntaxToken, typeAnnotation: TypeAnnotationSyntax) {
if (data) { this.__data = data; }
this.openBracketToken = openBracketToken, this.parameters = parameters, this.closeBracketToken = closeBracketToken, this.typeAnnotation = typeAnnotation;
openBracketToken.parent = this, parameters.parent = this, closeBracketToken.parent = this, typeAnnotation && (typeAnnotation.parent = this);
};
IndexSignatureSyntax.prototype.kind = function() { return SyntaxKind.IndexSignature; }
IndexSignatureSyntax.prototype.kind = SyntaxKind.IndexSignature;
export var MethodSignatureSyntax: MethodSignatureConstructor = <any>function(data: number, propertyName: ISyntaxToken, questionToken: ISyntaxToken, callSignature: CallSignatureSyntax) {
if (data) { this.__data = data; }
this.propertyName = propertyName, this.questionToken = questionToken, this.callSignature = callSignature;
propertyName.parent = this, questionToken && (questionToken.parent = this), callSignature.parent = this;
};
MethodSignatureSyntax.prototype.kind = function() { return SyntaxKind.MethodSignature; }
MethodSignatureSyntax.prototype.kind = SyntaxKind.MethodSignature;
export var BlockSyntax: BlockConstructor = <any>function(data: number, openBraceToken: ISyntaxToken, statements: IStatementSyntax[], closeBraceToken: ISyntaxToken) {
if (data) { this.__data = data; }
this.openBraceToken = openBraceToken, this.statements = statements, this.closeBraceToken = closeBraceToken;
openBraceToken.parent = this, statements.parent = this, closeBraceToken.parent = this;
};
BlockSyntax.prototype.kind = function() { return SyntaxKind.Block; }
BlockSyntax.prototype.kind = SyntaxKind.Block;
export var IfStatementSyntax: IfStatementConstructor = <any>function(data: number, ifKeyword: ISyntaxToken, openParenToken: ISyntaxToken, condition: IExpressionSyntax, closeParenToken: ISyntaxToken, statement: IStatementSyntax, elseClause: ElseClauseSyntax) {
if (data) { this.__data = data; }
this.ifKeyword = ifKeyword, this.openParenToken = openParenToken, this.condition = condition, this.closeParenToken = closeParenToken, this.statement = statement, this.elseClause = elseClause;
ifKeyword.parent = this, openParenToken.parent = this, condition.parent = this, closeParenToken.parent = this, statement.parent = this, elseClause && (elseClause.parent = this);
};
IfStatementSyntax.prototype.kind = function() { return SyntaxKind.IfStatement; }
IfStatementSyntax.prototype.kind = SyntaxKind.IfStatement;
export var VariableStatementSyntax: VariableStatementConstructor = <any>function(data: number, modifiers: ISyntaxToken[], variableDeclaration: VariableDeclarationSyntax, semicolonToken: ISyntaxToken) {
if (data) { this.__data = data; }
this.modifiers = modifiers, this.variableDeclaration = variableDeclaration, this.semicolonToken = semicolonToken;
modifiers.parent = this, variableDeclaration.parent = this, semicolonToken && (semicolonToken.parent = this);
};
VariableStatementSyntax.prototype.kind = function() { return SyntaxKind.VariableStatement; }
VariableStatementSyntax.prototype.kind = SyntaxKind.VariableStatement;
export var ExpressionStatementSyntax: ExpressionStatementConstructor = <any>function(data: number, expression: IExpressionSyntax, semicolonToken: ISyntaxToken) {
if (data) { this.__data = data; }
this.expression = expression, this.semicolonToken = semicolonToken;
expression.parent = this, semicolonToken && (semicolonToken.parent = this);
};
ExpressionStatementSyntax.prototype.kind = function() { return SyntaxKind.ExpressionStatement; }
ExpressionStatementSyntax.prototype.kind = SyntaxKind.ExpressionStatement;
export var ReturnStatementSyntax: ReturnStatementConstructor = <any>function(data: number, returnKeyword: ISyntaxToken, expression: IExpressionSyntax, semicolonToken: ISyntaxToken) {
if (data) { this.__data = data; }
this.returnKeyword = returnKeyword, this.expression = expression, this.semicolonToken = semicolonToken;
returnKeyword.parent = this, expression && (expression.parent = this), semicolonToken && (semicolonToken.parent = this);
};
ReturnStatementSyntax.prototype.kind = function() { return SyntaxKind.ReturnStatement; }
ReturnStatementSyntax.prototype.kind = SyntaxKind.ReturnStatement;
export var SwitchStatementSyntax: SwitchStatementConstructor = <any>function(data: number, switchKeyword: ISyntaxToken, openParenToken: ISyntaxToken, expression: IExpressionSyntax, closeParenToken: ISyntaxToken, openBraceToken: ISyntaxToken, switchClauses: ISwitchClauseSyntax[], closeBraceToken: ISyntaxToken) {
if (data) { this.__data = data; }
this.switchKeyword = switchKeyword, this.openParenToken = openParenToken, this.expression = expression, this.closeParenToken = closeParenToken, this.openBraceToken = openBraceToken, this.switchClauses = switchClauses, this.closeBraceToken = closeBraceToken;
switchKeyword.parent = this, openParenToken.parent = this, expression.parent = this, closeParenToken.parent = this, openBraceToken.parent = this, switchClauses.parent = this, closeBraceToken.parent = this;
};
SwitchStatementSyntax.prototype.kind = function() { return SyntaxKind.SwitchStatement; }
SwitchStatementSyntax.prototype.kind = SyntaxKind.SwitchStatement;
export var BreakStatementSyntax: BreakStatementConstructor = <any>function(data: number, breakKeyword: ISyntaxToken, identifier: ISyntaxToken, semicolonToken: ISyntaxToken) {
if (data) { this.__data = data; }
this.breakKeyword = breakKeyword, this.identifier = identifier, this.semicolonToken = semicolonToken;
breakKeyword.parent = this, identifier && (identifier.parent = this), semicolonToken && (semicolonToken.parent = this);
};
BreakStatementSyntax.prototype.kind = function() { return SyntaxKind.BreakStatement; }
BreakStatementSyntax.prototype.kind = SyntaxKind.BreakStatement;
export var ContinueStatementSyntax: ContinueStatementConstructor = <any>function(data: number, continueKeyword: ISyntaxToken, identifier: ISyntaxToken, semicolonToken: ISyntaxToken) {
if (data) { this.__data = data; }
this.continueKeyword = continueKeyword, this.identifier = identifier, this.semicolonToken = semicolonToken;
continueKeyword.parent = this, identifier && (identifier.parent = this), semicolonToken && (semicolonToken.parent = this);
};
ContinueStatementSyntax.prototype.kind = function() { return SyntaxKind.ContinueStatement; }
ContinueStatementSyntax.prototype.kind = SyntaxKind.ContinueStatement;
export var ForStatementSyntax: ForStatementConstructor = <any>function(data: number, forKeyword: ISyntaxToken, openParenToken: ISyntaxToken, variableDeclaration: VariableDeclarationSyntax, initializer: IExpressionSyntax, firstSemicolonToken: ISyntaxToken, condition: IExpressionSyntax, secondSemicolonToken: ISyntaxToken, incrementor: IExpressionSyntax, closeParenToken: ISyntaxToken, statement: IStatementSyntax) {
if (data) { this.__data = data; }
this.forKeyword = forKeyword, this.openParenToken = openParenToken, this.variableDeclaration = variableDeclaration, this.initializer = initializer, this.firstSemicolonToken = firstSemicolonToken, this.condition = condition, this.secondSemicolonToken = secondSemicolonToken, this.incrementor = incrementor, this.closeParenToken = closeParenToken, this.statement = statement;
forKeyword.parent = this, openParenToken.parent = this, variableDeclaration && (variableDeclaration.parent = this), initializer && (initializer.parent = this), firstSemicolonToken.parent = this, condition && (condition.parent = this), secondSemicolonToken.parent = this, incrementor && (incrementor.parent = this), closeParenToken.parent = this, statement.parent = this;
};
ForStatementSyntax.prototype.kind = function() { return SyntaxKind.ForStatement; }
ForStatementSyntax.prototype.kind = SyntaxKind.ForStatement;
export var ForInStatementSyntax: ForInStatementConstructor = <any>function(data: number, forKeyword: ISyntaxToken, openParenToken: ISyntaxToken, variableDeclaration: VariableDeclarationSyntax, left: IExpressionSyntax, inKeyword: ISyntaxToken, expression: IExpressionSyntax, closeParenToken: ISyntaxToken, statement: IStatementSyntax) {
if (data) { this.__data = data; }
this.forKeyword = forKeyword, this.openParenToken = openParenToken, this.variableDeclaration = variableDeclaration, this.left = left, this.inKeyword = inKeyword, this.expression = expression, this.closeParenToken = closeParenToken, this.statement = statement;
forKeyword.parent = this, openParenToken.parent = this, variableDeclaration && (variableDeclaration.parent = this), left && (left.parent = this), inKeyword.parent = this, expression.parent = this, closeParenToken.parent = this, statement.parent = this;
};
ForInStatementSyntax.prototype.kind = function() { return SyntaxKind.ForInStatement; }
ForInStatementSyntax.prototype.kind = SyntaxKind.ForInStatement;
export var EmptyStatementSyntax: EmptyStatementConstructor = <any>function(data: number, semicolonToken: ISyntaxToken) {
if (data) { this.__data = data; }
this.semicolonToken = semicolonToken;
semicolonToken.parent = this;
};
EmptyStatementSyntax.prototype.kind = function() { return SyntaxKind.EmptyStatement; }
EmptyStatementSyntax.prototype.kind = SyntaxKind.EmptyStatement;
export var ThrowStatementSyntax: ThrowStatementConstructor = <any>function(data: number, throwKeyword: ISyntaxToken, expression: IExpressionSyntax, semicolonToken: ISyntaxToken) {
if (data) { this.__data = data; }
this.throwKeyword = throwKeyword, this.expression = expression, this.semicolonToken = semicolonToken;
throwKeyword.parent = this, expression.parent = this, semicolonToken && (semicolonToken.parent = this);
};
ThrowStatementSyntax.prototype.kind = function() { return SyntaxKind.ThrowStatement; }
ThrowStatementSyntax.prototype.kind = SyntaxKind.ThrowStatement;
export var WhileStatementSyntax: WhileStatementConstructor = <any>function(data: number, whileKeyword: ISyntaxToken, openParenToken: ISyntaxToken, condition: IExpressionSyntax, closeParenToken: ISyntaxToken, statement: IStatementSyntax) {
if (data) { this.__data = data; }
this.whileKeyword = whileKeyword, this.openParenToken = openParenToken, this.condition = condition, this.closeParenToken = closeParenToken, this.statement = statement;
whileKeyword.parent = this, openParenToken.parent = this, condition.parent = this, closeParenToken.parent = this, statement.parent = this;
};
WhileStatementSyntax.prototype.kind = function() { return SyntaxKind.WhileStatement; }
WhileStatementSyntax.prototype.kind = SyntaxKind.WhileStatement;
export var TryStatementSyntax: TryStatementConstructor = <any>function(data: number, tryKeyword: ISyntaxToken, block: BlockSyntax, catchClause: CatchClauseSyntax, finallyClause: FinallyClauseSyntax) {
if (data) { this.__data = data; }
this.tryKeyword = tryKeyword, this.block = block, this.catchClause = catchClause, this.finallyClause = finallyClause;
tryKeyword.parent = this, block.parent = this, catchClause && (catchClause.parent = this), finallyClause && (finallyClause.parent = this);
};
TryStatementSyntax.prototype.kind = function() { return SyntaxKind.TryStatement; }
TryStatementSyntax.prototype.kind = SyntaxKind.TryStatement;
export var LabeledStatementSyntax: LabeledStatementConstructor = <any>function(data: number, identifier: ISyntaxToken, colonToken: ISyntaxToken, statement: IStatementSyntax) {
if (data) { this.__data = data; }
this.identifier = identifier, this.colonToken = colonToken, this.statement = statement;
identifier.parent = this, colonToken.parent = this, statement.parent = this;
};
LabeledStatementSyntax.prototype.kind = function() { return SyntaxKind.LabeledStatement; }
LabeledStatementSyntax.prototype.kind = SyntaxKind.LabeledStatement;
export var DoStatementSyntax: DoStatementConstructor = <any>function(data: number, doKeyword: ISyntaxToken, statement: IStatementSyntax, whileKeyword: ISyntaxToken, openParenToken: ISyntaxToken, condition: IExpressionSyntax, closeParenToken: ISyntaxToken, semicolonToken: ISyntaxToken) {
if (data) { this.__data = data; }
this.doKeyword = doKeyword, this.statement = statement, this.whileKeyword = whileKeyword, this.openParenToken = openParenToken, this.condition = condition, this.closeParenToken = closeParenToken, this.semicolonToken = semicolonToken;
doKeyword.parent = this, statement.parent = this, whileKeyword.parent = this, openParenToken.parent = this, condition.parent = this, closeParenToken.parent = this, semicolonToken && (semicolonToken.parent = this);
};
DoStatementSyntax.prototype.kind = function() { return SyntaxKind.DoStatement; }
DoStatementSyntax.prototype.kind = SyntaxKind.DoStatement;
export var DebuggerStatementSyntax: DebuggerStatementConstructor = <any>function(data: number, debuggerKeyword: ISyntaxToken, semicolonToken: ISyntaxToken) {
if (data) { this.__data = data; }
this.debuggerKeyword = debuggerKeyword, this.semicolonToken = semicolonToken;
debuggerKeyword.parent = this, semicolonToken && (semicolonToken.parent = this);
};
DebuggerStatementSyntax.prototype.kind = function() { return SyntaxKind.DebuggerStatement; }
DebuggerStatementSyntax.prototype.kind = SyntaxKind.DebuggerStatement;
export var WithStatementSyntax: WithStatementConstructor = <any>function(data: number, withKeyword: ISyntaxToken, openParenToken: ISyntaxToken, condition: IExpressionSyntax, closeParenToken: ISyntaxToken, statement: IStatementSyntax) {
if (data) { this.__data = data; }
this.withKeyword = withKeyword, this.openParenToken = openParenToken, this.condition = condition, this.closeParenToken = closeParenToken, this.statement = statement;
withKeyword.parent = this, openParenToken.parent = this, condition.parent = this, closeParenToken.parent = this, statement.parent = this;
};
WithStatementSyntax.prototype.kind = function() { return SyntaxKind.WithStatement; }
WithStatementSyntax.prototype.kind = SyntaxKind.WithStatement;
export var PrefixUnaryExpressionSyntax: PrefixUnaryExpressionConstructor = <any>function(data: number, operatorToken: ISyntaxToken, operand: IUnaryExpressionSyntax) {
if (data) { this.__data = data; }
this.operatorToken = operatorToken, this.operand = operand;
operatorToken.parent = this, operand.parent = this;
};
PrefixUnaryExpressionSyntax.prototype.kind = function() { return SyntaxKind.PrefixUnaryExpression; }
PrefixUnaryExpressionSyntax.prototype.kind = SyntaxKind.PrefixUnaryExpression;
export var DeleteExpressionSyntax: DeleteExpressionConstructor = <any>function(data: number, deleteKeyword: ISyntaxToken, expression: IUnaryExpressionSyntax) {
if (data) { this.__data = data; }
this.deleteKeyword = deleteKeyword, this.expression = expression;
deleteKeyword.parent = this, expression.parent = this;
};
DeleteExpressionSyntax.prototype.kind = function() { return SyntaxKind.DeleteExpression; }
DeleteExpressionSyntax.prototype.kind = SyntaxKind.DeleteExpression;
export var TypeOfExpressionSyntax: TypeOfExpressionConstructor = <any>function(data: number, typeOfKeyword: ISyntaxToken, expression: IUnaryExpressionSyntax) {
if (data) { this.__data = data; }
this.typeOfKeyword = typeOfKeyword, this.expression = expression;
typeOfKeyword.parent = this, expression.parent = this;
};
TypeOfExpressionSyntax.prototype.kind = function() { return SyntaxKind.TypeOfExpression; }
TypeOfExpressionSyntax.prototype.kind = SyntaxKind.TypeOfExpression;
export var VoidExpressionSyntax: VoidExpressionConstructor = <any>function(data: number, voidKeyword: ISyntaxToken, expression: IUnaryExpressionSyntax) {
if (data) { this.__data = data; }
this.voidKeyword = voidKeyword, this.expression = expression;
voidKeyword.parent = this, expression.parent = this;
};
VoidExpressionSyntax.prototype.kind = function() { return SyntaxKind.VoidExpression; }
VoidExpressionSyntax.prototype.kind = SyntaxKind.VoidExpression;
export var ConditionalExpressionSyntax: ConditionalExpressionConstructor = <any>function(data: number, condition: IExpressionSyntax, questionToken: ISyntaxToken, whenTrue: IExpressionSyntax, colonToken: ISyntaxToken, whenFalse: IExpressionSyntax) {
if (data) { this.__data = data; }
this.condition = condition, this.questionToken = questionToken, this.whenTrue = whenTrue, this.colonToken = colonToken, this.whenFalse = whenFalse;
condition.parent = this, questionToken.parent = this, whenTrue.parent = this, colonToken.parent = this, whenFalse.parent = this;
};
ConditionalExpressionSyntax.prototype.kind = function() { return SyntaxKind.ConditionalExpression; }
ConditionalExpressionSyntax.prototype.kind = SyntaxKind.ConditionalExpression;
export var BinaryExpressionSyntax: BinaryExpressionConstructor = <any>function(data: number, left: IExpressionSyntax, operatorToken: ISyntaxToken, right: IExpressionSyntax) {
if (data) { this.__data = data; }
this.left = left, this.operatorToken = operatorToken, this.right = right;
left.parent = this, operatorToken.parent = this, right.parent = this;
};
BinaryExpressionSyntax.prototype.kind = function() { return SyntaxKind.BinaryExpression; }
BinaryExpressionSyntax.prototype.kind = SyntaxKind.BinaryExpression;
export var PostfixUnaryExpressionSyntax: PostfixUnaryExpressionConstructor = <any>function(data: number, operand: ILeftHandSideExpressionSyntax, operatorToken: ISyntaxToken) {
if (data) { this.__data = data; }
this.operand = operand, this.operatorToken = operatorToken;
operand.parent = this, operatorToken.parent = this;
};
PostfixUnaryExpressionSyntax.prototype.kind = function() { return SyntaxKind.PostfixUnaryExpression; }
PostfixUnaryExpressionSyntax.prototype.kind = SyntaxKind.PostfixUnaryExpression;
export var MemberAccessExpressionSyntax: MemberAccessExpressionConstructor = <any>function(data: number, expression: ILeftHandSideExpressionSyntax, dotToken: ISyntaxToken, name: ISyntaxToken) {
if (data) { this.__data = data; }
this.expression = expression, this.dotToken = dotToken, this.name = name;
expression.parent = this, dotToken.parent = this, name.parent = this;
};
MemberAccessExpressionSyntax.prototype.kind = function() { return SyntaxKind.MemberAccessExpression; }
MemberAccessExpressionSyntax.prototype.kind = SyntaxKind.MemberAccessExpression;
export var InvocationExpressionSyntax: InvocationExpressionConstructor = <any>function(data: number, expression: ILeftHandSideExpressionSyntax, argumentList: ArgumentListSyntax) {
if (data) { this.__data = data; }
this.expression = expression, this.argumentList = argumentList;
expression.parent = this, argumentList.parent = this;
};
InvocationExpressionSyntax.prototype.kind = function() { return SyntaxKind.InvocationExpression; }
InvocationExpressionSyntax.prototype.kind = SyntaxKind.InvocationExpression;
export var ArrayLiteralExpressionSyntax: ArrayLiteralExpressionConstructor = <any>function(data: number, openBracketToken: ISyntaxToken, expressions: ISeparatedSyntaxList<IExpressionSyntax>, closeBracketToken: ISyntaxToken) {
if (data) { this.__data = data; }
this.openBracketToken = openBracketToken, this.expressions = expressions, this.closeBracketToken = closeBracketToken;
openBracketToken.parent = this, expressions.parent = this, closeBracketToken.parent = this;
};
ArrayLiteralExpressionSyntax.prototype.kind = function() { return SyntaxKind.ArrayLiteralExpression; }
ArrayLiteralExpressionSyntax.prototype.kind = SyntaxKind.ArrayLiteralExpression;
export var ObjectLiteralExpressionSyntax: ObjectLiteralExpressionConstructor = <any>function(data: number, openBraceToken: ISyntaxToken, propertyAssignments: ISeparatedSyntaxList<IPropertyAssignmentSyntax>, closeBraceToken: ISyntaxToken) {
if (data) { this.__data = data; }
this.openBraceToken = openBraceToken, this.propertyAssignments = propertyAssignments, this.closeBraceToken = closeBraceToken;
openBraceToken.parent = this, propertyAssignments.parent = this, closeBraceToken.parent = this;
};
ObjectLiteralExpressionSyntax.prototype.kind = function() { return SyntaxKind.ObjectLiteralExpression; }
ObjectLiteralExpressionSyntax.prototype.kind = SyntaxKind.ObjectLiteralExpression;
export var ObjectCreationExpressionSyntax: ObjectCreationExpressionConstructor = <any>function(data: number, newKeyword: ISyntaxToken, expression: IMemberExpressionSyntax, argumentList: ArgumentListSyntax) {
if (data) { this.__data = data; }
this.newKeyword = newKeyword, this.expression = expression, this.argumentList = argumentList;
newKeyword.parent = this, expression.parent = this, argumentList && (argumentList.parent = this);
};
ObjectCreationExpressionSyntax.prototype.kind = function() { return SyntaxKind.ObjectCreationExpression; }
ObjectCreationExpressionSyntax.prototype.kind = SyntaxKind.ObjectCreationExpression;
export var ParenthesizedExpressionSyntax: ParenthesizedExpressionConstructor = <any>function(data: number, openParenToken: ISyntaxToken, expression: IExpressionSyntax, closeParenToken: ISyntaxToken) {
if (data) { this.__data = data; }
this.openParenToken = openParenToken, this.expression = expression, this.closeParenToken = closeParenToken;
openParenToken.parent = this, expression.parent = this, closeParenToken.parent = this;
};
ParenthesizedExpressionSyntax.prototype.kind = function() { return SyntaxKind.ParenthesizedExpression; }
ParenthesizedExpressionSyntax.prototype.kind = SyntaxKind.ParenthesizedExpression;
export var ParenthesizedArrowFunctionExpressionSyntax: ParenthesizedArrowFunctionExpressionConstructor = <any>function(data: number, callSignature: CallSignatureSyntax, equalsGreaterThanToken: ISyntaxToken, block: BlockSyntax, expression: IExpressionSyntax) {
if (data) { this.__data = data; }
this.callSignature = callSignature, this.equalsGreaterThanToken = equalsGreaterThanToken, this.block = block, this.expression = expression;
callSignature.parent = this, equalsGreaterThanToken.parent = this, block && (block.parent = this), expression && (expression.parent = this);
};
ParenthesizedArrowFunctionExpressionSyntax.prototype.kind = function() { return SyntaxKind.ParenthesizedArrowFunctionExpression; }
ParenthesizedArrowFunctionExpressionSyntax.prototype.kind = SyntaxKind.ParenthesizedArrowFunctionExpression;
export var SimpleArrowFunctionExpressionSyntax: SimpleArrowFunctionExpressionConstructor = <any>function(data: number, parameter: ParameterSyntax, equalsGreaterThanToken: ISyntaxToken, block: BlockSyntax, expression: IExpressionSyntax) {
if (data) { this.__data = data; }
this.parameter = parameter, this.equalsGreaterThanToken = equalsGreaterThanToken, this.block = block, this.expression = expression;
parameter.parent = this, equalsGreaterThanToken.parent = this, block && (block.parent = this), expression && (expression.parent = this);
};
SimpleArrowFunctionExpressionSyntax.prototype.kind = function() { return SyntaxKind.SimpleArrowFunctionExpression; }
SimpleArrowFunctionExpressionSyntax.prototype.kind = SyntaxKind.SimpleArrowFunctionExpression;
export var CastExpressionSyntax: CastExpressionConstructor = <any>function(data: number, lessThanToken: ISyntaxToken, type: ITypeSyntax, greaterThanToken: ISyntaxToken, expression: IUnaryExpressionSyntax) {
if (data) { this.__data = data; }
this.lessThanToken = lessThanToken, this.type = type, this.greaterThanToken = greaterThanToken, this.expression = expression;
lessThanToken.parent = this, type.parent = this, greaterThanToken.parent = this, expression.parent = this;
};
CastExpressionSyntax.prototype.kind = function() { return SyntaxKind.CastExpression; }
CastExpressionSyntax.prototype.kind = SyntaxKind.CastExpression;
export var ElementAccessExpressionSyntax: ElementAccessExpressionConstructor = <any>function(data: number, expression: ILeftHandSideExpressionSyntax, openBracketToken: ISyntaxToken, argumentExpression: IExpressionSyntax, closeBracketToken: ISyntaxToken) {
if (data) { this.__data = data; }
this.expression = expression, this.openBracketToken = openBracketToken, this.argumentExpression = argumentExpression, this.closeBracketToken = closeBracketToken;
expression.parent = this, openBracketToken.parent = this, argumentExpression.parent = this, closeBracketToken.parent = this;
};
ElementAccessExpressionSyntax.prototype.kind = function() { return SyntaxKind.ElementAccessExpression; }
ElementAccessExpressionSyntax.prototype.kind = SyntaxKind.ElementAccessExpression;
export var FunctionExpressionSyntax: FunctionExpressionConstructor = <any>function(data: number, functionKeyword: ISyntaxToken, identifier: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax) {
if (data) { this.__data = data; }
this.functionKeyword = functionKeyword, this.identifier = identifier, this.callSignature = callSignature, this.block = block;
functionKeyword.parent = this, identifier && (identifier.parent = this), callSignature.parent = this, block.parent = this;
};
FunctionExpressionSyntax.prototype.kind = function() { return SyntaxKind.FunctionExpression; }
FunctionExpressionSyntax.prototype.kind = SyntaxKind.FunctionExpression;
export var OmittedExpressionSyntax: OmittedExpressionConstructor = <any>function(data: number) {
if (data) { this.__data = data; }
};
OmittedExpressionSyntax.prototype.kind = function() { return SyntaxKind.OmittedExpression; }
OmittedExpressionSyntax.prototype.kind = SyntaxKind.OmittedExpression;
export var TemplateExpressionSyntax: TemplateExpressionConstructor = <any>function(data: number, templateStartToken: ISyntaxToken, templateClauses: TemplateClauseSyntax[]) {
if (data) { this.__data = data; }
this.templateStartToken = templateStartToken, this.templateClauses = templateClauses;
templateStartToken.parent = this, templateClauses.parent = this;
};
TemplateExpressionSyntax.prototype.kind = function() { return SyntaxKind.TemplateExpression; }
TemplateExpressionSyntax.prototype.kind = SyntaxKind.TemplateExpression;
export var TemplateAccessExpressionSyntax: TemplateAccessExpressionConstructor = <any>function(data: number, expression: ILeftHandSideExpressionSyntax, templateExpression: IPrimaryExpressionSyntax) {
if (data) { this.__data = data; }
this.expression = expression, this.templateExpression = templateExpression;
expression.parent = this, templateExpression.parent = this;
};
TemplateAccessExpressionSyntax.prototype.kind = function() { return SyntaxKind.TemplateAccessExpression; }
TemplateAccessExpressionSyntax.prototype.kind = SyntaxKind.TemplateAccessExpression;
export var VariableDeclarationSyntax: VariableDeclarationConstructor = <any>function(data: number, varKeyword: ISyntaxToken, variableDeclarators: ISeparatedSyntaxList<VariableDeclaratorSyntax>) {
if (data) { this.__data = data; }
this.varKeyword = varKeyword, this.variableDeclarators = variableDeclarators;
varKeyword.parent = this, variableDeclarators.parent = this;
};
VariableDeclarationSyntax.prototype.kind = function() { return SyntaxKind.VariableDeclaration; }
VariableDeclarationSyntax.prototype.kind = SyntaxKind.VariableDeclaration;
export var VariableDeclaratorSyntax: VariableDeclaratorConstructor = <any>function(data: number, propertyName: ISyntaxToken, typeAnnotation: TypeAnnotationSyntax, equalsValueClause: EqualsValueClauseSyntax) {
if (data) { this.__data = data; }
this.propertyName = propertyName, this.typeAnnotation = typeAnnotation, this.equalsValueClause = equalsValueClause;
propertyName.parent = this, typeAnnotation && (typeAnnotation.parent = this), equalsValueClause && (equalsValueClause.parent = this);
};
VariableDeclaratorSyntax.prototype.kind = function() { return SyntaxKind.VariableDeclarator; }
VariableDeclaratorSyntax.prototype.kind = SyntaxKind.VariableDeclarator;
export var ArgumentListSyntax: ArgumentListConstructor = <any>function(data: number, typeArgumentList: TypeArgumentListSyntax, openParenToken: ISyntaxToken, _arguments: ISeparatedSyntaxList<IExpressionSyntax>, closeParenToken: ISyntaxToken) {
if (data) { this.__data = data; }
this.typeArgumentList = typeArgumentList, this.openParenToken = openParenToken, this.arguments = _arguments, this.closeParenToken = closeParenToken;
typeArgumentList && (typeArgumentList.parent = this), openParenToken.parent = this, _arguments.parent = this, closeParenToken.parent = this;
};
ArgumentListSyntax.prototype.kind = function() { return SyntaxKind.ArgumentList; }
ArgumentListSyntax.prototype.kind = SyntaxKind.ArgumentList;
export var ParameterListSyntax: ParameterListConstructor = <any>function(data: number, openParenToken: ISyntaxToken, parameters: ISeparatedSyntaxList<ParameterSyntax>, closeParenToken: ISyntaxToken) {
if (data) { this.__data = data; }
this.openParenToken = openParenToken, this.parameters = parameters, this.closeParenToken = closeParenToken;
openParenToken.parent = this, parameters.parent = this, closeParenToken.parent = this;
};
ParameterListSyntax.prototype.kind = function() { return SyntaxKind.ParameterList; }
ParameterListSyntax.prototype.kind = SyntaxKind.ParameterList;
export var TypeArgumentListSyntax: TypeArgumentListConstructor = <any>function(data: number, lessThanToken: ISyntaxToken, typeArguments: ISeparatedSyntaxList<ITypeSyntax>, greaterThanToken: ISyntaxToken) {
if (data) { this.__data = data; }
this.lessThanToken = lessThanToken, this.typeArguments = typeArguments, this.greaterThanToken = greaterThanToken;
lessThanToken.parent = this, typeArguments.parent = this, greaterThanToken.parent = this;
};
TypeArgumentListSyntax.prototype.kind = function() { return SyntaxKind.TypeArgumentList; }
TypeArgumentListSyntax.prototype.kind = SyntaxKind.TypeArgumentList;
export var TypeParameterListSyntax: TypeParameterListConstructor = <any>function(data: number, lessThanToken: ISyntaxToken, typeParameters: ISeparatedSyntaxList<TypeParameterSyntax>, greaterThanToken: ISyntaxToken) {
if (data) { this.__data = data; }
this.lessThanToken = lessThanToken, this.typeParameters = typeParameters, this.greaterThanToken = greaterThanToken;
lessThanToken.parent = this, typeParameters.parent = this, greaterThanToken.parent = this;
};
TypeParameterListSyntax.prototype.kind = function() { return SyntaxKind.TypeParameterList; }
TypeParameterListSyntax.prototype.kind = SyntaxKind.TypeParameterList;
export var HeritageClauseSyntax: HeritageClauseConstructor = <any>function(data: number, extendsOrImplementsKeyword: ISyntaxToken, typeNames: ISeparatedSyntaxList<INameSyntax>) {
if (data) { this.__data = data; }
this.extendsOrImplementsKeyword = extendsOrImplementsKeyword, this.typeNames = typeNames;
extendsOrImplementsKeyword.parent = this, typeNames.parent = this;
};
HeritageClauseSyntax.prototype.kind = function() { return SyntaxKind.HeritageClause; }
HeritageClauseSyntax.prototype.kind = SyntaxKind.HeritageClause;
export var EqualsValueClauseSyntax: EqualsValueClauseConstructor = <any>function(data: number, equalsToken: ISyntaxToken, value: IExpressionSyntax) {
if (data) { this.__data = data; }
this.equalsToken = equalsToken, this.value = value;
equalsToken.parent = this, value.parent = this;
};
EqualsValueClauseSyntax.prototype.kind = function() { return SyntaxKind.EqualsValueClause; }
EqualsValueClauseSyntax.prototype.kind = SyntaxKind.EqualsValueClause;
export var CaseSwitchClauseSyntax: CaseSwitchClauseConstructor = <any>function(data: number, caseKeyword: ISyntaxToken, expression: IExpressionSyntax, colonToken: ISyntaxToken, statements: IStatementSyntax[]) {
if (data) { this.__data = data; }
this.caseKeyword = caseKeyword, this.expression = expression, this.colonToken = colonToken, this.statements = statements;
caseKeyword.parent = this, expression.parent = this, colonToken.parent = this, statements.parent = this;
};
CaseSwitchClauseSyntax.prototype.kind = function() { return SyntaxKind.CaseSwitchClause; }
CaseSwitchClauseSyntax.prototype.kind = SyntaxKind.CaseSwitchClause;
export var DefaultSwitchClauseSyntax: DefaultSwitchClauseConstructor = <any>function(data: number, defaultKeyword: ISyntaxToken, colonToken: ISyntaxToken, statements: IStatementSyntax[]) {
if (data) { this.__data = data; }
this.defaultKeyword = defaultKeyword, this.colonToken = colonToken, this.statements = statements;
defaultKeyword.parent = this, colonToken.parent = this, statements.parent = this;
};
DefaultSwitchClauseSyntax.prototype.kind = function() { return SyntaxKind.DefaultSwitchClause; }
DefaultSwitchClauseSyntax.prototype.kind = SyntaxKind.DefaultSwitchClause;
export var ElseClauseSyntax: ElseClauseConstructor = <any>function(data: number, elseKeyword: ISyntaxToken, statement: IStatementSyntax) {
if (data) { this.__data = data; }
this.elseKeyword = elseKeyword, this.statement = statement;
elseKeyword.parent = this, statement.parent = this;
};
ElseClauseSyntax.prototype.kind = function() { return SyntaxKind.ElseClause; }
ElseClauseSyntax.prototype.kind = SyntaxKind.ElseClause;
export var CatchClauseSyntax: CatchClauseConstructor = <any>function(data: number, catchKeyword: ISyntaxToken, openParenToken: ISyntaxToken, identifier: ISyntaxToken, typeAnnotation: TypeAnnotationSyntax, closeParenToken: ISyntaxToken, block: BlockSyntax) {
if (data) { this.__data = data; }
this.catchKeyword = catchKeyword, this.openParenToken = openParenToken, this.identifier = identifier, this.typeAnnotation = typeAnnotation, this.closeParenToken = closeParenToken, this.block = block;
catchKeyword.parent = this, openParenToken.parent = this, identifier.parent = this, typeAnnotation && (typeAnnotation.parent = this), closeParenToken.parent = this, block.parent = this;
};
CatchClauseSyntax.prototype.kind = function() { return SyntaxKind.CatchClause; }
CatchClauseSyntax.prototype.kind = SyntaxKind.CatchClause;
export var FinallyClauseSyntax: FinallyClauseConstructor = <any>function(data: number, finallyKeyword: ISyntaxToken, block: BlockSyntax) {
if (data) { this.__data = data; }
this.finallyKeyword = finallyKeyword, this.block = block;
finallyKeyword.parent = this, block.parent = this;
};
FinallyClauseSyntax.prototype.kind = function() { return SyntaxKind.FinallyClause; }
FinallyClauseSyntax.prototype.kind = SyntaxKind.FinallyClause;
export var TemplateClauseSyntax: TemplateClauseConstructor = <any>function(data: number, expression: IExpressionSyntax, templateMiddleOrEndToken: ISyntaxToken) {
if (data) { this.__data = data; }
this.expression = expression, this.templateMiddleOrEndToken = templateMiddleOrEndToken;
expression.parent = this, templateMiddleOrEndToken.parent = this;
};
TemplateClauseSyntax.prototype.kind = function() { return SyntaxKind.TemplateClause; }
TemplateClauseSyntax.prototype.kind = SyntaxKind.TemplateClause;
export var TypeParameterSyntax: TypeParameterConstructor = <any>function(data: number, identifier: ISyntaxToken, constraint: ConstraintSyntax) {
if (data) { this.__data = data; }
this.identifier = identifier, this.constraint = constraint;
identifier.parent = this, constraint && (constraint.parent = this);
};
TypeParameterSyntax.prototype.kind = function() { return SyntaxKind.TypeParameter; }
TypeParameterSyntax.prototype.kind = SyntaxKind.TypeParameter;
export var ConstraintSyntax: ConstraintConstructor = <any>function(data: number, extendsKeyword: ISyntaxToken, typeOrExpression: ISyntaxNodeOrToken) {
if (data) { this.__data = data; }
this.extendsKeyword = extendsKeyword, this.typeOrExpression = typeOrExpression;
extendsKeyword.parent = this, typeOrExpression.parent = this;
};
ConstraintSyntax.prototype.kind = function() { return SyntaxKind.Constraint; }
ConstraintSyntax.prototype.kind = SyntaxKind.Constraint;
export var SimplePropertyAssignmentSyntax: SimplePropertyAssignmentConstructor = <any>function(data: number, propertyName: ISyntaxToken, colonToken: ISyntaxToken, expression: IExpressionSyntax) {
if (data) { this.__data = data; }
this.propertyName = propertyName, this.colonToken = colonToken, this.expression = expression;
propertyName.parent = this, colonToken.parent = this, expression.parent = this;
};
SimplePropertyAssignmentSyntax.prototype.kind = function() { return SyntaxKind.SimplePropertyAssignment; }
SimplePropertyAssignmentSyntax.prototype.kind = SyntaxKind.SimplePropertyAssignment;
export var FunctionPropertyAssignmentSyntax: FunctionPropertyAssignmentConstructor = <any>function(data: number, propertyName: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax) {
if (data) { this.__data = data; }
this.propertyName = propertyName, this.callSignature = callSignature, this.block = block;
propertyName.parent = this, callSignature.parent = this, block.parent = this;
};
FunctionPropertyAssignmentSyntax.prototype.kind = function() { return SyntaxKind.FunctionPropertyAssignment; }
FunctionPropertyAssignmentSyntax.prototype.kind = SyntaxKind.FunctionPropertyAssignment;
export var ParameterSyntax: ParameterConstructor = <any>function(data: number, dotDotDotToken: ISyntaxToken, modifiers: ISyntaxToken[], identifier: ISyntaxToken, questionToken: ISyntaxToken, typeAnnotation: TypeAnnotationSyntax, equalsValueClause: EqualsValueClauseSyntax) {
if (data) { this.__data = data; }
this.dotDotDotToken = dotDotDotToken, this.modifiers = modifiers, this.identifier = identifier, this.questionToken = questionToken, this.typeAnnotation = typeAnnotation, this.equalsValueClause = equalsValueClause;
dotDotDotToken && (dotDotDotToken.parent = this), modifiers.parent = this, identifier.parent = this, questionToken && (questionToken.parent = this), typeAnnotation && (typeAnnotation.parent = this), equalsValueClause && (equalsValueClause.parent = this);
};
ParameterSyntax.prototype.kind = function() { return SyntaxKind.Parameter; }
ParameterSyntax.prototype.kind = SyntaxKind.Parameter;
export var EnumElementSyntax: EnumElementConstructor = <any>function(data: number, propertyName: ISyntaxToken, equalsValueClause: EqualsValueClauseSyntax) {
if (data) { this.__data = data; }
this.propertyName = propertyName, this.equalsValueClause = equalsValueClause;
propertyName.parent = this, equalsValueClause && (equalsValueClause.parent = this);
};
EnumElementSyntax.prototype.kind = function() { return SyntaxKind.EnumElement; }
EnumElementSyntax.prototype.kind = SyntaxKind.EnumElement;
export var TypeAnnotationSyntax: TypeAnnotationConstructor = <any>function(data: number, colonToken: ISyntaxToken, type: ITypeSyntax) {
if (data) { this.__data = data; }
this.colonToken = colonToken, this.type = type;
colonToken.parent = this, type.parent = this;
};
TypeAnnotationSyntax.prototype.kind = function() { return SyntaxKind.TypeAnnotation; }
TypeAnnotationSyntax.prototype.kind = SyntaxKind.TypeAnnotation;
export var ExternalModuleReferenceSyntax: ExternalModuleReferenceConstructor = <any>function(data: number, requireKeyword: ISyntaxToken, openParenToken: ISyntaxToken, stringLiteral: ISyntaxToken, closeParenToken: ISyntaxToken) {
if (data) { this.__data = data; }
this.requireKeyword = requireKeyword, this.openParenToken = openParenToken, this.stringLiteral = stringLiteral, this.closeParenToken = closeParenToken;
requireKeyword.parent = this, openParenToken.parent = this, stringLiteral.parent = this, closeParenToken.parent = this;
};
ExternalModuleReferenceSyntax.prototype.kind = function() { return SyntaxKind.ExternalModuleReference; }
ExternalModuleReferenceSyntax.prototype.kind = SyntaxKind.ExternalModuleReference;
export var ModuleNameModuleReferenceSyntax: ModuleNameModuleReferenceConstructor = <any>function(data: number, moduleName: INameSyntax) {
if (data) { this.__data = data; }
this.moduleName = moduleName;
moduleName.parent = this;
};
ModuleNameModuleReferenceSyntax.prototype.kind = function() { return SyntaxKind.ModuleNameModuleReference; }
ModuleNameModuleReferenceSyntax.prototype.kind = SyntaxKind.ModuleNameModuleReference;
}

View File

@ -74,7 +74,7 @@ module TypeScript {
return undefined;
}
var kind = token.kind();
var kind = token.kind;
var text = token.text();
if (kind === SyntaxKind.IdentifierName) {
@ -284,7 +284,7 @@ module TypeScript {
module TypeScript.Syntax {
export function realizeToken(token: ISyntaxToken, text: ISimpleText): ISyntaxToken {
return new RealizedToken(token.fullStart(), token.kind(), token.isKeywordConvertedToIdentifier(), token.leadingTrivia(text), token.text(), token.trailingTrivia(text));
return new RealizedToken(token.fullStart(), token.kind, token.isKeywordConvertedToIdentifier(), token.leadingTrivia(text), token.text(), token.trailingTrivia(text));
}
export function convertKeywordToIdentifier(token: ISyntaxToken): ISyntaxToken {
@ -292,11 +292,11 @@ module TypeScript.Syntax {
}
export function withLeadingTrivia(token: ISyntaxToken, leadingTrivia: ISyntaxTriviaList, text: ISimpleText): ISyntaxToken {
return new RealizedToken(token.fullStart(), token.kind(), token.isKeywordConvertedToIdentifier(), leadingTrivia, token.text(), token.trailingTrivia(text));
return new RealizedToken(token.fullStart(), token.kind, token.isKeywordConvertedToIdentifier(), leadingTrivia, token.text(), token.trailingTrivia(text));
}
export function withTrailingTrivia(token: ISyntaxToken, trailingTrivia: ISyntaxTriviaList, text: ISimpleText): ISyntaxToken {
return new RealizedToken(token.fullStart(), token.kind(), token.isKeywordConvertedToIdentifier(), token.leadingTrivia(text), token.text(), trailingTrivia);
return new RealizedToken(token.fullStart(), token.kind, token.isKeywordConvertedToIdentifier(), token.leadingTrivia(text), token.text(), trailingTrivia);
}
export function emptyToken(kind: SyntaxKind): ISyntaxToken {
@ -307,23 +307,19 @@ module TypeScript.Syntax {
public _primaryExpressionBrand: any; public _memberExpressionBrand: any; public _leftHandSideExpressionBrand: any; public _postfixExpressionBrand: any; public _unaryExpressionBrand: any; public _expressionBrand: any; public _typeBrand: any; public _syntaxNodeOrTokenBrand: any;
public parent: ISyntaxElement;
constructor(private _kind: SyntaxKind) {
constructor(public kind: SyntaxKind) {
}
public setFullStart(fullStart: number): void {
// An empty token is always at the -1 position.
}
public kind(): SyntaxKind {
return this._kind;
}
public childCount() { return 0 }
public childAt(index: number): ISyntaxElement { throw Errors.invalidOperation() }
public accept(visitor: ISyntaxVisitor): any { return visitor.visitToken(this) }
public clone(): ISyntaxToken {
return new EmptyToken(this.kind());
return new EmptyToken(this.kind);
}
// Empty tokens are never incrementally reusable.
@ -363,7 +359,7 @@ module TypeScript.Syntax {
while (true) {
var parent = current.parent;
if (parent === undefined) {
Debug.assert(current.kind() === SyntaxKind.SourceUnit, "We had a node without a parent that was not the root node!");
Debug.assert(current.kind === SyntaxKind.SourceUnit, "We had a node without a parent that was not the root node!");
// We walked all the way to the top, and never found a previous element. This
// can happen with code like:
@ -422,7 +418,6 @@ module TypeScript.Syntax {
class RealizedToken implements ISyntaxToken {
private _fullStart: number;
private _kind: SyntaxKind;
private _isKeywordConvertedToIdentifier: boolean;
private _leadingTrivia: ISyntaxTriviaList;
private _text: string;
@ -432,13 +427,12 @@ module TypeScript.Syntax {
public parent: ISyntaxElement;
constructor(fullStart: number,
kind: SyntaxKind,
public kind: SyntaxKind,
isKeywordConvertedToIdentifier: boolean,
leadingTrivia: ISyntaxTriviaList,
text: string,
trailingTrivia: ISyntaxTriviaList) {
this._fullStart = fullStart;
this._kind = kind;
this._isKeywordConvertedToIdentifier = isKeywordConvertedToIdentifier;
this._text = text;
@ -458,16 +452,12 @@ module TypeScript.Syntax {
this._fullStart = fullStart;
}
public kind(): SyntaxKind {
return this._kind;
}
public childCount() { return 0 }
public childAt(index: number): ISyntaxElement { throw Errors.invalidOperation() }
public accept(visitor: ISyntaxVisitor): any { return visitor.visitToken(this) }
public clone(): ISyntaxToken {
return new RealizedToken(this._fullStart, this.kind(), this._isKeywordConvertedToIdentifier, this._leadingTrivia, this._text, this._trailingTrivia);
return new RealizedToken(this._fullStart, this.kind, this._isKeywordConvertedToIdentifier, this._leadingTrivia, this._text, this._trailingTrivia);
}
// Realized tokens are created from the parser. They are *never* incrementally reusable.
@ -500,14 +490,11 @@ module TypeScript.Syntax {
class ConvertedKeywordToken implements ISyntaxToken {
public _primaryExpressionBrand: any; public _memberExpressionBrand: any; public _leftHandSideExpressionBrand: any; public _postfixExpressionBrand: any; public _unaryExpressionBrand: any; public _expressionBrand: any; public _typeBrand: any; public _syntaxNodeOrTokenBrand: any;
public parent: ISyntaxElement;
public kind: SyntaxKind;
constructor(private underlyingToken: ISyntaxToken) {
}
public kind() {
return SyntaxKind.IdentifierName;
}
public setFullStart(fullStart: number): void {
this.underlyingToken.setFullStart(fullStart);
}
@ -594,4 +581,5 @@ module TypeScript.Syntax {
return new ConvertedKeywordToken(this.underlyingToken);
}
}
ConvertedKeywordToken.prototype.kind = SyntaxKind.IdentifierName;
}

View File

@ -231,7 +231,7 @@ module TypeScript {
}
private checkParameterAccessibilityModifier(parameterList: ParameterListSyntax, modifier: ISyntaxToken, modifierIndex: number): boolean {
if (!SyntaxFacts.isAccessibilityModifier(modifier.kind())) {
if (!SyntaxFacts.isAccessibilityModifier(modifier.kind)) {
this.pushDiagnostic(modifier, DiagnosticCode._0_modifier_cannot_appear_on_a_parameter, [modifier.text()]);
return true;
}
@ -280,7 +280,7 @@ module TypeScript {
public visitHeritageClause(node: HeritageClauseSyntax): void {
if (this.checkForTrailingComma(node.typeNames) ||
this.checkForAtLeastOneElement(node.typeNames, node.extendsOrImplementsKeyword, SyntaxFacts.getText(node.extendsOrImplementsKeyword.kind()))) {
this.checkForAtLeastOneElement(node.typeNames, node.extendsOrImplementsKeyword, SyntaxFacts.getText(node.extendsOrImplementsKeyword.kind))) {
return;
}
@ -359,8 +359,8 @@ module TypeScript {
this.pushDiagnostic(parameter, DiagnosticCode.Index_signature_parameter_must_have_a_type_annotation);
return true;
}
else if (parameter.typeAnnotation.type.kind() !== SyntaxKind.StringKeyword &&
parameter.typeAnnotation.type.kind() !== SyntaxKind.NumberKeyword) {
else if (parameter.typeAnnotation.type.kind !== SyntaxKind.StringKeyword &&
parameter.typeAnnotation.type.kind !== SyntaxKind.NumberKeyword) {
this.pushDiagnostic(parameter, DiagnosticCode.Index_signature_parameter_type_must_be_string_or_number);
return true;
}
@ -389,7 +389,7 @@ module TypeScript {
Debug.assert(i <= 2);
var heritageClause = node.heritageClauses[i];
if (heritageClause.extendsOrImplementsKeyword.kind() === SyntaxKind.ExtendsKeyword) {
if (heritageClause.extendsOrImplementsKeyword.kind === SyntaxKind.ExtendsKeyword) {
if (seenExtendsClause) {
this.pushDiagnostic(heritageClause, DiagnosticCode.extends_clause_already_seen);
return true;
@ -408,7 +408,7 @@ module TypeScript {
seenExtendsClause = true;
}
else {
Debug.assert(heritageClause.extendsOrImplementsKeyword.kind() === SyntaxKind.ImplementsKeyword);
Debug.assert(heritageClause.extendsOrImplementsKeyword.kind === SyntaxKind.ImplementsKeyword);
if (seenImplementsClause) {
this.pushDiagnostic(heritageClause, DiagnosticCode.implements_clause_already_seen);
return true;
@ -468,7 +468,7 @@ module TypeScript {
Debug.assert(i <= 1);
var heritageClause = node.heritageClauses[i];
if (heritageClause.extendsOrImplementsKeyword.kind() === SyntaxKind.ExtendsKeyword) {
if (heritageClause.extendsOrImplementsKeyword.kind === SyntaxKind.ExtendsKeyword) {
if (seenExtendsClause) {
this.pushDiagnostic(heritageClause, DiagnosticCode.extends_clause_already_seen);
return true;
@ -477,7 +477,7 @@ module TypeScript {
seenExtendsClause = true;
}
else {
Debug.assert(heritageClause.extendsOrImplementsKeyword.kind() === SyntaxKind.ImplementsKeyword);
Debug.assert(heritageClause.extendsOrImplementsKeyword.kind === SyntaxKind.ImplementsKeyword);
this.pushDiagnostic(heritageClause, DiagnosticCode.Interface_declaration_cannot_have_implements_clause);
return true;
}
@ -489,7 +489,7 @@ module TypeScript {
private checkInterfaceModifiers(modifiers: ISyntaxToken[]): boolean {
for (var i = 0, n = modifiers.length; i < n; i++) {
var modifier = modifiers[i];
if (modifier.kind() === SyntaxKind.DeclareKeyword) {
if (modifier.kind === SyntaxKind.DeclareKeyword) {
this.pushDiagnostic(modifier,
DiagnosticCode.A_declare_modifier_cannot_be_used_with_an_interface_declaration);
return true;
@ -516,7 +516,7 @@ module TypeScript {
for (var i = 0, n = list.length; i < n; i++) {
var modifier = list[i];
if (SyntaxFacts.isAccessibilityModifier(modifier.kind())) {
if (SyntaxFacts.isAccessibilityModifier(modifier.kind)) {
if (seenAccessibilityModifier) {
this.pushDiagnostic(modifier, DiagnosticCode.Accessibility_modifier_already_seen);
return true;
@ -530,7 +530,7 @@ module TypeScript {
seenAccessibilityModifier = true;
}
else if (modifier.kind() === SyntaxKind.StaticKeyword) {
else if (modifier.kind === SyntaxKind.StaticKeyword) {
if (seenStaticModifier) {
this.pushDiagnostic(modifier, DiagnosticCode._0_modifier_already_seen, [modifier.text()]);
return true;
@ -763,7 +763,7 @@ module TypeScript {
}
public visitInvocationExpression(node: InvocationExpressionSyntax): void {
if (node.expression.kind() === SyntaxKind.SuperKeyword &&
if (node.expression.kind === SyntaxKind.SuperKeyword &&
node.argumentList.typeArgumentList) {
this.pushDiagnostic(node, DiagnosticCode.super_invocation_cannot_have_type_arguments);
}
@ -777,13 +777,13 @@ module TypeScript {
for (var i = 0, n = modifiers.length; i < n; i++) {
var modifier = modifiers[i];
if (SyntaxFacts.isAccessibilityModifier(modifier.kind()) ||
modifier.kind() === SyntaxKind.StaticKeyword) {
if (SyntaxFacts.isAccessibilityModifier(modifier.kind) ||
modifier.kind === SyntaxKind.StaticKeyword) {
this.pushDiagnostic(modifier, DiagnosticCode._0_modifier_cannot_appear_on_a_module_element, [modifier.text()]);
return true;
}
if (modifier.kind() === SyntaxKind.DeclareKeyword) {
if (modifier.kind === SyntaxKind.DeclareKeyword) {
if (seenDeclareModifier) {
this.pushDiagnostic(modifier, DiagnosticCode.Accessibility_modifier_already_seen);
return;
@ -791,7 +791,7 @@ module TypeScript {
seenDeclareModifier = true;
}
else if (modifier.kind() === SyntaxKind.ExportKeyword) {
else if (modifier.kind === SyntaxKind.ExportKeyword) {
if (seenExportModifier) {
this.pushDiagnostic(modifier, DiagnosticCode._0_modifier_already_seen, [modifier.text()]);
return;
@ -814,9 +814,9 @@ module TypeScript {
if (!node.stringLiteral) {
for (var i = 0, n = node.moduleElements.length; i < n; i++) {
var child = node.moduleElements[i];
if (child.kind() === SyntaxKind.ImportDeclaration) {
if (child.kind === SyntaxKind.ImportDeclaration) {
var importDeclaration = <ImportDeclarationSyntax>child;
if (importDeclaration.moduleReference.kind() === SyntaxKind.ExternalModuleReference) {
if (importDeclaration.moduleReference.kind === SyntaxKind.ExternalModuleReference) {
this.pushDiagnostic(importDeclaration, DiagnosticCode.Import_declarations_in_an_internal_module_cannot_reference_an_external_module);
}
}
@ -874,7 +874,7 @@ module TypeScript {
for (var i = 0, n = node.moduleElements.length; i < n; i++) {
var child = node.moduleElements[i];
if (child.kind() === SyntaxKind.ExportAssignment) {
if (child.kind === SyntaxKind.ExportAssignment) {
this.pushDiagnostic(child, DiagnosticCode.Export_assignment_cannot_be_used_in_internal_modules);
return true;
}
@ -898,7 +898,7 @@ module TypeScript {
if (this.inAmbientDeclaration || this.syntaxTree.isDeclaration()) {
// Provide a specialized message for a block as a statement versus the block as a
// function body.
if (node.parent.kind() === SyntaxKind.List) {
if (node.parent.kind === SyntaxKind.List) {
this.pushDiagnostic(firstToken(node), DiagnosticCode.Statements_are_not_allowed_in_ambient_contexts);
}
else {
@ -979,7 +979,7 @@ module TypeScript {
private inSwitchStatement(ast: ISyntaxElement): boolean {
while (ast) {
if (ast.kind() === SyntaxKind.SwitchStatement) {
if (ast.kind === SyntaxKind.SwitchStatement) {
return true;
}
@ -994,7 +994,7 @@ module TypeScript {
}
private isIterationStatement(ast: ISyntaxElement): boolean {
switch (ast.kind()) {
switch (ast.kind) {
case SyntaxKind.ForStatement:
case SyntaxKind.ForInStatement:
case SyntaxKind.WhileStatement:
@ -1026,7 +1026,7 @@ module TypeScript {
element = element.parent;
while (element) {
if (element.kind() === SyntaxKind.LabeledStatement) {
if (element.kind === SyntaxKind.LabeledStatement) {
var labeledStatement = <LabeledStatementSyntax>element;
if (breakable) {
// Breakable labels can be placed on any construct
@ -1052,7 +1052,7 @@ module TypeScript {
}
private labelIsOnContinuableConstruct(statement: ISyntaxElement): boolean {
switch (statement.kind()) {
switch (statement.kind) {
case SyntaxKind.LabeledStatement:
// Labels work transitively. i.e. if you have:
// foo:
@ -1363,7 +1363,7 @@ module TypeScript {
private checkListSeparators<T extends ISyntaxNodeOrToken>(list: ISeparatedSyntaxList<T>, kind: SyntaxKind): boolean {
for (var i = 0, n = separatorCount(list); i < n; i++) {
var child = separatorAt(list, i);
if (child.kind() !== kind) {
if (child.kind !== kind) {
this.pushDiagnostic(child, DiagnosticCode._0_expected, [SyntaxFacts.getText(kind)]);
}
}
@ -1418,7 +1418,7 @@ module TypeScript {
}
private checkForTemplatePropertyName(token: ISyntaxToken): boolean {
if (token.kind() === SyntaxKind.NoSubstitutionTemplateToken) {
if (token.kind === SyntaxKind.NoSubstitutionTemplateToken) {
this.pushDiagnostic(token, DiagnosticCode.Template_literal_cannot_be_used_as_an_element_name);
return true;
}
@ -1427,7 +1427,7 @@ module TypeScript {
}
private checkVariableDeclaratorIdentifier(node: VariableDeclaratorSyntax): boolean {
if (node.parent.kind() !== SyntaxKind.MemberVariableDeclaration) {
if (node.parent.kind !== SyntaxKind.MemberVariableDeclaration) {
if (this.checkForDisallowedEvalOrArguments(node, node.propertyName)) {
return true;
}
@ -1460,8 +1460,8 @@ module TypeScript {
private checkConstructorModifiers(modifiers: ISyntaxToken[]): boolean {
for (var i = 0, n = modifiers.length; i < n; i++) {
var child = modifiers[i];
if (child.kind() !== SyntaxKind.PublicKeyword) {
this.pushDiagnostic(child, DiagnosticCode._0_modifier_cannot_appear_on_a_constructor_declaration, [SyntaxFacts.getText(child.kind())]);
if (child.kind !== SyntaxKind.PublicKeyword) {
this.pushDiagnostic(child, DiagnosticCode._0_modifier_cannot_appear_on_a_constructor_declaration, [SyntaxFacts.getText(child.kind)]);
return true;
}
}
@ -1531,7 +1531,7 @@ module TypeScript {
}
private isPreIncrementOrDecrementExpression(node: PrefixUnaryExpressionSyntax) {
switch (node.operatorToken.kind()) {
switch (node.operatorToken.kind) {
case SyntaxKind.MinusMinusToken:
case SyntaxKind.PlusPlusToken:
return true;
@ -1541,7 +1541,7 @@ module TypeScript {
}
public visitDeleteExpression(node: DeleteExpressionSyntax): void {
if (parsedInStrictMode(node) && node.expression.kind() === SyntaxKind.IdentifierName) {
if (parsedInStrictMode(node) && node.expression.kind === SyntaxKind.IdentifierName) {
this.pushDiagnostic(firstToken(node), DiagnosticCode.delete_cannot_be_called_on_an_identifier_in_strict_mode);
return;
}
@ -1550,7 +1550,7 @@ module TypeScript {
}
private checkIllegalAssignment(node: BinaryExpressionSyntax): boolean {
if (parsedInStrictMode(node) && SyntaxFacts.isAssignmentOperatorToken(node.operatorToken.kind()) && this.isEvalOrArguments(node.left)) {
if (parsedInStrictMode(node) && SyntaxFacts.isAssignmentOperatorToken(node.operatorToken.kind) && this.isEvalOrArguments(node.left)) {
this.pushDiagnostic(node.operatorToken, DiagnosticCode.Invalid_use_of_0_in_strict_mode, [this.getEvalOrArguments(node.left)]);
return true;
}
@ -1559,7 +1559,7 @@ module TypeScript {
}
private getEvalOrArguments(expr: IExpressionSyntax): string {
if (expr.kind() === SyntaxKind.IdentifierName) {
if (expr.kind === SyntaxKind.IdentifierName) {
var text = tokenValueText(<ISyntaxToken>expr);
if (text === "eval" || text === "arguments") {
return text;
@ -1582,7 +1582,7 @@ module TypeScript {
}
private checkConstraintType(node: ConstraintSyntax): boolean {
if (!SyntaxFacts.isType(node.typeOrExpression.kind())) {
if (!SyntaxFacts.isType(node.typeOrExpression.kind)) {
this.pushDiagnostic(node.typeOrExpression, DiagnosticCode.Type_expected);
return true;
}
@ -1639,13 +1639,13 @@ module TypeScript {
var moduleElement = node.moduleElements[i];
var _firstToken = firstToken(moduleElement);
if (_firstToken && _firstToken.kind() === SyntaxKind.ExportKeyword) {
if (_firstToken && _firstToken.kind === SyntaxKind.ExportKeyword) {
return new TextSpan(start(_firstToken), width(_firstToken));
}
if (moduleElement.kind() === SyntaxKind.ImportDeclaration) {
if (moduleElement.kind === SyntaxKind.ImportDeclaration) {
var importDecl = <ImportDeclarationSyntax>moduleElement;
if (importDecl.moduleReference.kind() === SyntaxKind.ExternalModuleReference) {
if (importDecl.moduleReference.kind === SyntaxKind.ExternalModuleReference) {
var literal = (<TypeScript.ExternalModuleReferenceSyntax>importDecl.moduleReference).stringLiteral;
return new TextSpan(start(literal), width(literal));
}

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,7 @@
module TypeScript {
export class SyntaxUtilities {
public static isAnyFunctionExpressionOrDeclaration(ast: ISyntaxElement): boolean {
switch (ast.kind()) {
switch (ast.kind) {
case SyntaxKind.SimpleArrowFunctionExpression:
case SyntaxKind.ParenthesizedArrowFunctionExpression:
case SyntaxKind.FunctionExpression:
@ -34,7 +34,7 @@ module TypeScript {
public static isLeftHandSizeExpression(element: ISyntaxElement) {
if (element) {
switch (element.kind()) {
switch (element.kind) {
case SyntaxKind.MemberAccessExpression:
case SyntaxKind.ElementAccessExpression:
case SyntaxKind.TemplateAccessExpression:
@ -62,7 +62,7 @@ module TypeScript {
public static isSwitchClause(element: ISyntaxElement) {
if (element) {
switch (element.kind()) {
switch (element.kind) {
case SyntaxKind.CaseSwitchClause:
case SyntaxKind.DefaultSwitchClause:
return true;
@ -74,7 +74,7 @@ module TypeScript {
public static isTypeMember(element: ISyntaxElement) {
if (element) {
switch (element.kind()) {
switch (element.kind) {
case SyntaxKind.ConstructSignature:
case SyntaxKind.MethodSignature:
case SyntaxKind.IndexSignature:
@ -89,7 +89,7 @@ module TypeScript {
public static isClassElement(element: ISyntaxElement) {
if (element) {
switch (element.kind()) {
switch (element.kind) {
case SyntaxKind.ConstructorDeclaration:
case SyntaxKind.IndexMemberDeclaration:
case SyntaxKind.MemberFunctionDeclaration:
@ -106,7 +106,7 @@ module TypeScript {
public static isModuleElement(element: ISyntaxElement) {
if (element) {
switch (element.kind()) {
switch (element.kind) {
case SyntaxKind.ImportDeclaration:
case SyntaxKind.ExportAssignment:
case SyntaxKind.ClassDeclaration:
@ -143,7 +143,7 @@ module TypeScript {
public static isStatement(element: ISyntaxElement) {
if (element) {
switch (element.kind()) {
switch (element.kind) {
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.VariableStatement:
case SyntaxKind.Block:
@ -173,8 +173,8 @@ module TypeScript {
public static isAngleBracket(positionedElement: ISyntaxElement): boolean {
var element = positionedElement;
var parent = positionedElement.parent;
if (parent && (element.kind() === SyntaxKind.LessThanToken || element.kind() === SyntaxKind.GreaterThanToken)) {
switch (parent.kind()) {
if (parent && (element.kind === SyntaxKind.LessThanToken || element.kind === SyntaxKind.GreaterThanToken)) {
switch (parent.kind) {
case SyntaxKind.TypeArgumentList:
case SyntaxKind.TypeParameterList:
case SyntaxKind.CastExpression:
@ -188,7 +188,7 @@ module TypeScript {
public static getToken(list: ISyntaxToken[], kind: SyntaxKind): ISyntaxToken {
for (var i = 0, n = list.length; i < n; i++) {
var token = list[i];
if (token.kind() === kind) {
if (token.kind === kind) {
return token;
}
}
@ -205,7 +205,7 @@ module TypeScript {
}
public static getExportKeyword(moduleElement: IModuleElementSyntax): ISyntaxToken {
switch (moduleElement.kind()) {
switch (moduleElement.kind) {
case SyntaxKind.ModuleDeclaration:
case SyntaxKind.ClassDeclaration:
case SyntaxKind.FunctionDeclaration:
@ -225,7 +225,7 @@ module TypeScript {
}
var node = positionNode;
switch (node.kind()) {
switch (node.kind) {
case SyntaxKind.ModuleDeclaration:
case SyntaxKind.ClassDeclaration:
case SyntaxKind.FunctionDeclaration:

View File

@ -3,7 +3,7 @@
module TypeScript {
export function visitNodeOrToken(visitor: ISyntaxVisitor, element: ISyntaxNodeOrToken): any {
if (element === undefined) { return undefined; }
switch (element.kind()) {
switch (element.kind) {
case SyntaxKind.SourceUnit: return visitor.visitSourceUnit(<SourceUnitSyntax>element);
case SyntaxKind.QualifiedName: return visitor.visitQualifiedName(<QualifiedNameSyntax>element);
case SyntaxKind.ObjectType: return visitor.visitObjectType(<ObjectTypeSyntax>element);

View File

@ -9,10 +9,10 @@ module TypeScript {
if (node1 === node2) { return true; }
if (!node1 || !node2) { return false; }
Debug.assert(node1.kind() === TypeScript.SyntaxKind.SourceUnit || node1.parent);
Debug.assert(node2.kind() === TypeScript.SyntaxKind.SourceUnit || node2.parent);
Debug.assert(node1.kind === TypeScript.SyntaxKind.SourceUnit || node1.parent);
Debug.assert(node2.kind === TypeScript.SyntaxKind.SourceUnit || node2.parent);
if (node1.kind() !== node2.kind()) { return false; }
if (node1.kind !== node2.kind) { return false; }
if (childCount(node1) !== childCount(node2)) { return false; }
for (var i = 0, n = childCount(node1); i < n; i++) {
@ -41,8 +41,8 @@ module TypeScript {
return false;
}
Debug.assert(node1.kind() === TypeScript.SyntaxKind.SourceUnit || node1.parent);
Debug.assert(node2.kind() === TypeScript.SyntaxKind.SourceUnit || node2.parent);
Debug.assert(node1.kind === TypeScript.SyntaxKind.SourceUnit || node1.parent);
Debug.assert(node2.kind === TypeScript.SyntaxKind.SourceUnit || node2.parent);
if (TypeScript.isToken(node1)) {
return TypeScript.isToken(node2) ? tokenStructuralEquals(<TypeScript.ISyntaxToken>node1, <TypeScript.ISyntaxToken>node2, text1, text2) : false;
@ -63,7 +63,7 @@ module TypeScript {
Debug.assert(token1.parent);
Debug.assert(token2.parent);
return token1.kind() === token2.kind() &&
return token1.kind === token2.kind &&
TypeScript.width(token1) === TypeScript.width(token2) &&
token1.fullWidth() === token2.fullWidth() &&
token1.fullStart() === token2.fullStart() &&
@ -135,10 +135,10 @@ module TypeScript {
return false;
}
Debug.assert(element1.kind() === SyntaxKind.SourceUnit || element1.parent);
Debug.assert(element2.kind() === SyntaxKind.SourceUnit || element2.parent);
Debug.assert(element1.kind === SyntaxKind.SourceUnit || element1.parent);
Debug.assert(element2.kind === SyntaxKind.SourceUnit || element2.parent);
if (element2.kind() !== element2.kind()) {
if (element2.kind !== element2.kind) {
return false;
}

View File

@ -0,0 +1,4 @@
var fixedWidthArray = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 4, 5, 8, 8, 7, 6, 2, 4, 5, 7, 3, 8, 2, 2, 10, 3, 4, 6, 6, 4, 5, 4, 3, 6, 3, 4, 5, 4, 5, 5, 4, 6, 7, 6, 5, 10, 9, 3, 7, 7, 9, 6, 6, 5, 3, 7, 11, 7, 3, 6, 7, 6, 3, 6, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 1, 1, 1, 1, 2, 2, 2, 2, 3, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 2, 2, 2, 2, 3, 3, 4, 2, 2, 2, 1, 2];
function fixedWidthTokenLength(kind: SyntaxKind) {
return fixedWidthArray[kind];
}