Merge pull request #2131 from Microsoft/deleteUnusedFiles

delete unused files
This commit is contained in:
Mohamed Hegazy 2015-02-24 14:37:17 -08:00
commit 1b7dea0577
77 changed files with 0 additions and 31058 deletions

File diff suppressed because it is too large Load diff

View file

@ -1,6 +0,0 @@
declare class Enumerator {
public atEnd(): boolean;
public moveNext(): boolean;
public item(): any;
constructor (o: any);
}

View file

@ -1,187 +0,0 @@
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
///<reference path='references.ts' />
module TypeScript {
var proto = "__proto__";
class BlockIntrinsics<T> {
public prototype: T = undefined;
public toString: T = undefined;
public toLocaleString: T = undefined;
public valueOf: T = undefined;
public hasOwnProperty: T = undefined;
public propertyIsEnumerable: T = undefined;
public isPrototypeOf: T = undefined;
[s: string]: T;
constructor() {
// initialize the 'constructor' field
this["constructor"] = undefined;
// First we set it to null, because that's the only way to erase the value in node. Then we set it to undefined in case we are not in node, since
// in StringHashTable below, we check for undefined explicitly.
this[proto] = null;
this[proto] = undefined;
}
}
export function createIntrinsicsObject<T>(): ts.Map<T> {
return new BlockIntrinsics<T>();
}
//export interface IHashTable<T> {
// getAllKeys(): string[];
// add(key: string, data: T): boolean;
// addOrUpdate(key: string, data: T): boolean;
// map(fn: (k: string, value: T, context: any) => void , context: any): void;
// every(fn: (k: string, value: T, context: any) => void , context: any): boolean;
// some(fn: (k: string, value: T, context: any) => void , context: any): boolean;
// count(): number;
// lookup(key: string): T;
//}
//export class StringHashTable<T> implements IHashTable<T> {
// private itemCount = 0;
// private table: IIndexable<T> = createIntrinsicsObject<T>();
// public getAllKeys(): string[] {
// var result: string[] = [];
// for (var k in this.table) {
// if (this.table[k] !== undefined) {
// result.push(k);
// }
// }
// return result;
// }
// public add(key: string, data: T): boolean {
// if (this.table[key] !== undefined) {
// return false;
// }
// this.table[key] = data;
// this.itemCount++;
// return true;
// }
// public addOrUpdate(key: string, data: T): boolean {
// if (this.table[key] !== undefined) {
// this.table[key] = data;
// return false;
// }
// this.table[key] = data;
// this.itemCount++;
// return true;
// }
// public map(fn: (k: string, value: T, context: any) => void , context: any) {
// for (var k in this.table) {
// var data = this.table[k];
// if (data !== undefined) {
// fn(k, this.table[k], context);
// }
// }
// }
// public every(fn: (k: string, value: T, context: any) => void , context: any) {
// for (var k in this.table) {
// var data = this.table[k];
// if (data !== undefined) {
// if (!fn(k, this.table[k], context)) {
// return false;
// }
// }
// }
// return true;
// }
// public some(fn: (k: string, value: T, context: any) => void , context: any) {
// for (var k in this.table) {
// var data = this.table[k];
// if (data !== undefined) {
// if (fn(k, this.table[k], context)) {
// return true;
// }
// }
// }
// return false;
// }
// public count(): number {
// return this.itemCount;
// }
// public lookup(key: string) : T {
// var data = this.table[key];
// return data === undefined ? null : data;
// }
// public remove(key: string): void {
// if (this.table[key] !== undefined) {
// this.table[key] = undefined;
// this.itemCount--;
// }
// }
//}
//export class IdentiferNameHashTable<T> extends StringHashTable<T> {
// public getAllKeys(): string[]{
// var result: string[] = [];
// super.map((k, v, c) => {
// if (v !== undefined) {
// result.push(k.substring(1));
// }
// }, null);
// return result;
// }
// public add(key: string, data: T): boolean {
// return super.add("#" + key, data);
// }
// public addOrUpdate(key: string, data: T): boolean {
// return super.addOrUpdate("#" + key, data);
// }
// public map(fn: (k: string, value: T, context: any) => void , context: any) {
// return super.map((k, v, c) => fn(k.substring(1), v, c), context);
// }
// public every(fn: (k: string, value: T, context: any) => void , context: any) {
// return super.every((k, v, c) => fn(k.substring(1), v, c), context);
// }
// public some(fn: (k: string, value: any, context: any) => void , context: any) {
// return super.some((k, v, c) => fn(k.substring(1), v, c), context);
// }
// public lookup(key: string): T {
// return super.lookup("#" + key);
// }
//}
}

View file

@ -1,11 +0,0 @@
module TypeScript {
export class IdentifierWalker extends SyntaxWalker {
constructor(public list: IIndexable<boolean>) {
super();
}
public visitToken(token: ISyntaxToken): void {
this.list[token.text()] = true;
}
}
}

View file

@ -1,64 +0,0 @@
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
///<reference path='enumerator.ts' />
///<reference path='process.ts' />
///<reference path='core\references.ts' />
module TypeScript {
export interface IFindFileResult {
fileInformation: FileInformation;
path: string;
}
export module IOUtils {
// Creates the directory including its parent if not already present
function createDirectoryStructure(ioHost: IEnvironment, dirName: string) {
if (ioHost.directoryExists(dirName)) {
return;
}
var parentDirectory = ioHost.directoryName(dirName);
if (parentDirectory != "") {
createDirectoryStructure(ioHost, parentDirectory);
}
ioHost.createDirectory(dirName);
}
// Creates a file including its directory structure if not already present
export function writeFileAndFolderStructure(ioHost: IEnvironment, fileName: string, contents: string, writeByteOrderMark: boolean): void {
var start = new Date().getTime();
var path = ioHost.absolutePath(fileName);
TypeScript.ioHostResolvePathTime += new Date().getTime() - start;
var start = new Date().getTime();
var dirName = ioHost.directoryName(path);
TypeScript.ioHostDirectoryNameTime += new Date().getTime() - start;
var start = new Date().getTime();
createDirectoryStructure(ioHost, dirName);
TypeScript.ioHostCreateDirectoryStructureTime += new Date().getTime() - start;
var start = new Date().getTime();
ioHost.writeFile(path, contents, writeByteOrderMark);
TypeScript.ioHostWriteFileTime += new Date().getTime() - start;
}
export function combine(prefix: string, suffix: string): string {
return prefix + "/" + suffix;
}
}
}

View file

@ -1,29 +0,0 @@
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
///<reference path='references.ts' />
module TypeScript {
function isFileOfExtension(fname: string, ext: string) {
var invariantFname = fname.toLocaleUpperCase();
var invariantExt = ext.toLocaleUpperCase();
var extLength = invariantExt.length;
return invariantFname.length > extLength && invariantFname.substring(invariantFname.length - extLength, invariantFname.length) === invariantExt;
}
export function isDTSFile(fname: string) {
return isFileOfExtension(fname, ".d.ts");
}
}

View file

@ -1,17 +0,0 @@
//declare module process {
// export var argv: string[];
// export var platform: string;
// export function on(event: string, handler: (arg: any) => void ): void;
// export module stdout {
// export function write(str: string): any;
// export function on(event: string, action: () => void ): void;
// }
// export module stderr {
// export function write(str: string): any;
// export function on(event: string, action: () => void): void;
// }
// export module mainModule {
// export var filename: string;
// }
// export function exit(exitCode?: number): any;
//}

View file

@ -1,32 +0,0 @@
/////<reference path='resources\references.ts' />
/////<reference path='core\references.ts' />
/////<reference path='text\references.ts' />
/////<reference path='syntax\references.ts' />
/////<reference path='diagnostics.ts' />
/////<reference path='document.ts' />
/////<reference path='flags.ts' />
/////<reference path='hashTable.ts' />
/////<reference path='base64.ts' />
/////<reference path='sourceMapping.ts' />
/////<reference path='emitter.ts' />
/////<reference path='pathUtils.ts' />
/////<reference path='referenceResolution.ts' />
/////<reference path='precompile.ts' />
/////<reference path='referenceResolver.ts' />
/////<reference path='declarationEmitter.ts' />
/////<reference path='identifierWalker.ts' />
/////<reference path='settings.ts' />
/////<reference path='typecheck\pullFlags.ts' />
/////<reference path='typecheck\pullDecls.ts' />
/////<reference path='typecheck\pullSymbols.ts' />
/////<reference path='typecheck\pullTypeEnclosingTypeWalker.ts' />
/////<reference path='typecheck\pullTypeResolutionContext.ts' />
/////<reference path='typecheck\pullTypeResolution.ts' />
/////<reference path='typecheck\pullSemanticInfo.ts' />
/////<reference path='typecheck\pullDeclCollection.ts' />
/////<reference path='typecheck\pullSymbolBinder.ts' />
/////<reference path='typecheck\pullHelpers.ts' />
/////<reference path='typecheck\pullInstantiationHelpers.ts' />
/////<reference path='typecheck\pullTypeInstantiation.ts' />
/////<reference path='typescript.ts' />

View file

@ -1,270 +0,0 @@
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
///<reference path='references.ts' />
module TypeScript {
export class SourceMapPosition {
public sourceLine: number;
public sourceColumn: number;
public emittedLine: number;
public emittedColumn: number;
}
export class SourceMapping {
public start = new SourceMapPosition();
public end = new SourceMapPosition();
public nameIndex: number = -1;
public childMappings: SourceMapping[] = [];
}
export class SourceMapEntry {
constructor(
public emittedFile: string,
public emittedLine: number,
public emittedColumn: number,
public sourceFile: string,
public sourceLine: number,
public sourceColumn: number,
public sourceName: string) {
Debug.assert(isFinite(emittedLine));
Debug.assert(isFinite(emittedColumn));
Debug.assert(isFinite(sourceColumn));
Debug.assert(isFinite(sourceLine));
}
}
export class SourceMapper {
static MapFileExtension = ".map";
private jsFileName: string;
private sourceMapPath: string;
private sourceMapDirectory: string;
private sourceRoot: string;
public names: string[] = [];
private mappingLevel: ISpan[] = [];
// Below two arrays represent the information about sourceFile at that index.
private tsFilePaths: string[] = [];
private allSourceMappings: SourceMapping[][] = [];
public currentMappings: SourceMapping[][];
public currentNameIndex: number[];
private sourceMapEntries: SourceMapEntry[] = [];
constructor(private jsFile: TextWriter,
private sourceMapOut: TextWriter,
document: Document,
jsFilePath: string,
emitOptions: EmitOptions,
resolvePath: (path: string) => string) {
this.setSourceMapOptions(document, jsFilePath, emitOptions, resolvePath);
this.setNewSourceFile(document, emitOptions);
}
public getOutputFile(): OutputFile {
var result = this.sourceMapOut.getOutputFile();
result.sourceMapEntries = this.sourceMapEntries;
return result;
}
public increaseMappingLevel(ast: ISpan) {
this.mappingLevel.push(ast);
}
public decreaseMappingLevel(ast: any) {
Debug.assert(this.mappingLevel.length > 0, "Mapping level should never be less than 0. This suggests a missing start call.");
var expectedAst = this.mappingLevel.pop();
if (ast !== expectedAst) {
var expectedAstInfo: any = (<any>expectedAst).kind ? SyntaxKind[(<any>expectedAst).kind] : [expectedAst.start(), expectedAst.end()];
var astInfo: any = (<any>ast).kind ? SyntaxKind[(<any>ast).kind] : [ast.start(), ast.end()];
Debug.fail(
"Provided ast is not the expected ISyntaxElement, Expected: " + expectedAstInfo + " Given: " + astInfo);
}
}
public setNewSourceFile(document: Document, emitOptions: EmitOptions) {
// Set new mappings
var sourceMappings: SourceMapping[] = [];
this.allSourceMappings.push(sourceMappings);
this.currentMappings = [sourceMappings];
this.currentNameIndex = [];
// Set new source file path
this.setNewSourceFilePath(document, emitOptions);
}
private setSourceMapOptions(document: Document, jsFilePath: string, emitOptions: EmitOptions, resolvePath: (path: string) => string) {
// Decode mapRoot and sourceRoot
// Js File Name = pretty name of js file
var prettyJsFileName = TypeScript.getPrettyName(jsFilePath, false, true);
var prettyMapFileName = prettyJsFileName + SourceMapper.MapFileExtension;
this.jsFileName = prettyJsFileName;
// Figure out sourceMapPath and sourceMapDirectory
if (emitOptions.sourceMapRootDirectory()) {
// Get the sourceMap Directory
this.sourceMapDirectory = emitOptions.sourceMapRootDirectory();
if (document.emitToOwnOutputFile()) {
// For modules or multiple emit files the mapRoot will have directory structure like the sources
// So if src\a.ts and src\lib\b.ts are compiled together user would be moving the maps into mapRoot\a.js.map and mapRoot\lib\b.js.map
this.sourceMapDirectory = this.sourceMapDirectory + switchToForwardSlashes(getRootFilePath((document.fileName)).replace(emitOptions.commonDirectoryPath(), ""));
}
if (isRelative(this.sourceMapDirectory)) {
// The relative paths are relative to the common directory
this.sourceMapDirectory = emitOptions.commonDirectoryPath() + this.sourceMapDirectory;
this.sourceMapDirectory = convertToDirectoryPath(switchToForwardSlashes(resolvePath(this.sourceMapDirectory)));
this.sourceMapPath = getRelativePathToFixedPath(getRootFilePath(jsFilePath), this.sourceMapDirectory + prettyMapFileName);
}
else {
this.sourceMapPath = this.sourceMapDirectory + prettyMapFileName;
}
}
else {
this.sourceMapPath = prettyMapFileName;
this.sourceMapDirectory = getRootFilePath(jsFilePath);
}
this.sourceRoot = emitOptions.sourceRootDirectory();
}
private setNewSourceFilePath(document: Document, emitOptions: EmitOptions) {
var tsFilePath = switchToForwardSlashes(document.fileName);
if (emitOptions.sourceRootDirectory()) {
// Use the relative path corresponding to the common directory path
tsFilePath = getRelativePathToFixedPath(emitOptions.commonDirectoryPath(), tsFilePath);
}
else {
// Source locations relative to map file location
tsFilePath = getRelativePathToFixedPath(this.sourceMapDirectory, tsFilePath);
}
this.tsFilePaths.push(tsFilePath);
}
// Generate source mapping.
// Creating files can cause exceptions, they will be caught higher up in TypeScriptCompiler.emit
public emitSourceMapping(): void {
Debug.assert(
this.mappingLevel.length === 0,
"Mapping level is not 0. This suggest a missing end call. Value: " +
this.mappingLevel.map(item => ['Node of type', SyntaxKind[(<any>item).kind], 'at', item.start(), 'to', item.end()].join(' ')).join(', '));
// Output map file name into the js file
this.jsFile.WriteLine("//# sourceMappingURL=" + this.sourceMapPath);
// Now output map file
var mappingsString = "";
var prevEmittedColumn = 0;
var prevEmittedLine = 0;
var prevSourceColumn = 0;
var prevSourceLine = 0;
var prevSourceIndex = 0;
var prevNameIndex = 0;
var emitComma = false;
var recordedPosition: SourceMapPosition = null;
for (var sourceIndex = 0; sourceIndex < this.tsFilePaths.length; sourceIndex++) {
var recordSourceMapping = (mappedPosition: SourceMapPosition, nameIndex: number) => {
if (recordedPosition !== null &&
recordedPosition.emittedColumn === mappedPosition.emittedColumn &&
recordedPosition.emittedLine === mappedPosition.emittedLine) {
// This position is already recorded
return;
}
// Record this position
if (prevEmittedLine !== mappedPosition.emittedLine) {
while (prevEmittedLine < mappedPosition.emittedLine) {
prevEmittedColumn = 0;
mappingsString = mappingsString + ";";
prevEmittedLine++;
}
emitComma = false;
}
else if (emitComma) {
mappingsString = mappingsString + ",";
}
this.sourceMapEntries.push(new SourceMapEntry(
this.jsFileName,
mappedPosition.emittedLine + 1,
mappedPosition.emittedColumn + 1,
this.tsFilePaths[sourceIndex],
mappedPosition.sourceLine,
mappedPosition.sourceColumn + 1,
nameIndex >= 0 ? this.names[nameIndex] : undefined));
// 1. Relative Column
mappingsString = mappingsString + Base64VLQFormat.encode(mappedPosition.emittedColumn - prevEmittedColumn);
prevEmittedColumn = mappedPosition.emittedColumn;
// 2. Relative sourceIndex
mappingsString = mappingsString + Base64VLQFormat.encode(sourceIndex - prevSourceIndex);
prevSourceIndex = sourceIndex;
// 3. Relative sourceLine 0 based
mappingsString = mappingsString + Base64VLQFormat.encode(mappedPosition.sourceLine - 1 - prevSourceLine);
prevSourceLine = mappedPosition.sourceLine - 1;
// 4. Relative sourceColumn 0 based
mappingsString = mappingsString + Base64VLQFormat.encode(mappedPosition.sourceColumn - prevSourceColumn);
prevSourceColumn = mappedPosition.sourceColumn;
// 5. Relative namePosition 0 based
if (nameIndex >= 0) {
mappingsString = mappingsString + Base64VLQFormat.encode(nameIndex - prevNameIndex);
prevNameIndex = nameIndex;
}
emitComma = true;
recordedPosition = mappedPosition;
};
// Record starting spans
var recordSourceMappingSiblings = (sourceMappings: SourceMapping[]) => {
for (var i = 0; i < sourceMappings.length; i++) {
var sourceMapping = sourceMappings[i];
recordSourceMapping(sourceMapping.start, sourceMapping.nameIndex);
recordSourceMappingSiblings(sourceMapping.childMappings);
recordSourceMapping(sourceMapping.end, sourceMapping.nameIndex);
}
};
recordSourceMappingSiblings(this.allSourceMappings[sourceIndex]);
}
// Write the actual map file
this.sourceMapOut.Write(JSON.stringify({
version: 3,
file: this.jsFileName,
sourceRoot: this.sourceRoot,
sources: this.tsFilePaths,
names: this.names,
mappings: mappingsString
}));
// Closing files could result in exceptions, report them if they occur
this.sourceMapOut.Close();
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,31 +0,0 @@
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
///<reference path='typescript.ts' />
module Tools {
export interface IWalkContext {
goChildren: boolean;
goNextSibling: boolean;
// visit siblings in reverse execution order
reverseSiblings: boolean;
}
export class BaseWalkContext implements IWalkContext {
public goChildren = true;
public goNextSibling = true;
public reverseSiblings = false;
}
}

View file

@ -1,205 +0,0 @@
///<reference path='references.ts' />
module TypeScript {
export class ArrayUtilities {
public static sequenceEquals<T>(array1: T[], array2: T[], equals: (v1: T, v2: T) => boolean) {
if (array1 === array2) {
return true;
}
if (!array1 || !array2) {
return false;
}
if (array1.length !== array2.length) {
return false;
}
for (var i = 0, n = array1.length; i < n; i++) {
if (!equals(array1[i], array2[i])) {
return false;
}
}
return true;
}
public static contains<T>(array: T[], value: T): boolean {
for (var i = 0; i < array.length; i++) {
if (array[i] === value) {
return true;
}
}
return false;
}
// Gets unique element array
public static distinct<T>(array: T[], equalsFn?: (a: T, b: T) => boolean): T[] {
var result: T[] = [];
// TODO: use map when available
for (var i = 0, n = array.length; i < n; i++) {
var current = array[i];
for (var j = 0; j < result.length; j++) {
if (equalsFn(result[j], current)) {
break;
}
}
if (j === result.length) {
result.push(current);
}
}
return result;
}
public static last<T>(array: T[]): T {
if (array.length === 0) {
throw Errors.argumentOutOfRange('array');
}
return array[array.length - 1];
}
public static lastOrDefault<T>(array: T[], predicate: (v: T, index: number) => boolean): T {
for (var i = array.length - 1; i >= 0; i--) {
var v = array[i];
if (predicate(v, i)) {
return v;
}
}
return undefined;
}
public static firstOrDefault<T>(array: T[], func: (v: T, index: number) => boolean): T {
for (var i = 0, n = array.length; i < n; i++) {
var value = array[i];
if (func(value, i)) {
return value;
}
}
return undefined;
}
public static first<T>(array: T[], func?: (v: T, index: number) => boolean): T {
for (var i = 0, n = array.length; i < n; i++) {
var value = array[i];
if (!func || func(value, i)) {
return value;
}
}
throw Errors.invalidOperation();
}
public static sum<T>(array: T[], func: (v: T) => number): number {
var result = 0;
for (var i = 0, n = array.length; i < n; i++) {
result += func(array[i]);
}
return result;
}
public static select<T,S>(values: T[], func: (v: T) => S): S[] {
var result: S[] = new Array<S>(values.length);
for (var i = 0; i < values.length; i++) {
result[i] = func(values[i]);
}
return result;
}
public static where<T>(values: T[], func: (v: T) => boolean): T[] {
var result = new Array<T>();
for (var i = 0; i < values.length; i++) {
if (func(values[i])) {
result.push(values[i]);
}
}
return result;
}
public static any<T>(array: T[], func: (v: T) => boolean): boolean {
for (var i = 0, n = array.length; i < n; i++) {
if (func(array[i])) {
return true;
}
}
return false;
}
public static all<T>(array: T[], func: (v: T) => boolean): boolean {
for (var i = 0, n = array.length; i < n; i++) {
if (!func(array[i])) {
return false;
}
}
return true;
}
public static binarySearch(array: number[], value: number): number {
var low = 0;
var high = array.length - 1;
while (low <= high) {
var middle = low + ((high - low) >> 1);
var midValue = array[middle];
if (midValue === value) {
return middle;
}
else if (midValue > value) {
high = middle - 1;
}
else {
low = middle + 1;
}
}
return ~low;
}
public static createArray<T>(length: number, defaultValue: any): T[] {
var result = new Array<T>(length);
for (var i = 0; i < length; i++) {
result[i] = defaultValue;
}
return result;
}
public static grow<T>(array: T[], length: number, defaultValue: T): void {
var count = length - array.length;
for (var i = 0; i < count; i++) {
array.push(defaultValue);
}
}
public static copy<T>(sourceArray: T[], sourceIndex: number, destinationArray: T[], destinationIndex: number, length: number): void {
for (var i = 0; i < length; i++) {
destinationArray[destinationIndex + i] = sourceArray[sourceIndex + i];
}
}
public static indexOf<T>(array: T[], predicate: (v: T) => boolean): number {
for (var i = 0, n = array.length; i < n; i++) {
if (predicate(array[i])) {
return i;
}
}
return -1;
}
}
}

View file

@ -1,33 +0,0 @@
///<reference path='references.ts' />
module TypeScript {
export enum AssertionLevel {
None = 0,
Normal = 1,
Aggressive = 2,
VeryAggressive = 3,
}
export class Debug {
private static currentAssertionLevel = AssertionLevel.None;
public static shouldAssert(level: AssertionLevel): boolean {
return this.currentAssertionLevel >= level;
}
public static assert(expression: any, message?: string, verboseDebugInfo?: () => string): void {
if (!expression) {
var verboseDebugString = "";
if (verboseDebugInfo) {
verboseDebugString = "\r\nVerbose Debug Information:" + verboseDebugInfo();
}
message = message || "";
throw new Error("Debug Failure. False expression: " + message + verboseDebugString);
}
}
public static fail(message?: string): void {
Debug.assert(false, message);
}
}
}

View file

@ -1,10 +0,0 @@
///<reference path='references.ts' />
module TypeScript {
export enum DiagnosticCategory {
Warning,
Error,
Message,
NoPrefix,
}
}

View file

@ -1,195 +0,0 @@
///<reference path='references.ts' />
module TypeScript {
export class Location {
private _fileName: string;
private _lineMap: LineMap;
private _start: number;
private _length: number;
constructor(fileName: string, lineMap: LineMap, start: number, length: number) {
this._fileName = fileName;
this._lineMap = lineMap;
this._start = start;
this._length = length;
}
public fileName(): string {
return this._fileName;
}
public lineMap(): LineMap {
return this._lineMap;
}
public line(): number {
return this._lineMap ? this._lineMap.getLineNumberFromPosition(this.start()) : 0;
}
public character(): number {
return this._lineMap ? this._lineMap.getLineAndCharacterFromPosition(this.start()).character() : 0;
}
public start(): number {
return this._start;
}
public length(): number {
return this._length;
}
public static equals(location1: Location, location2: Location): boolean {
return location1._fileName === location2._fileName &&
location1._start === location2._start &&
location1._length === location2._length;
}
}
export class Diagnostic extends Location {
private _diagnosticKey: string;
private _arguments: any[];
private _additionalLocations: Location[];
constructor(fileName: string, lineMap: LineMap, start: number, length: number, diagnosticKey: string, _arguments?: any[], additionalLocations?: Location[]) {
super(fileName, lineMap, start, length);
this._diagnosticKey = diagnosticKey;
this._arguments = (_arguments && _arguments.length > 0) ? _arguments : undefined;
this._additionalLocations = (additionalLocations && additionalLocations.length > 0) ? additionalLocations : undefined;
}
public toJSON(key: any): any {
var result: any = {};
result.start = this.start();
result.length = this.length();
result.diagnosticCode = this._diagnosticKey;
var _arguments: any[] = (<any>this).arguments();
if (_arguments && _arguments.length > 0) {
result.arguments = _arguments;
}
return result;
}
public diagnosticKey(): string {
return this._diagnosticKey;
}
public arguments(): any[] {
return this._arguments;
}
/**
* Get the text of the message in the given language.
*/
public text(): string {
return TypeScript.getLocalizedText(this._diagnosticKey, this._arguments);
}
/**
* Get the text of the message including the error code in the given language.
*/
public message(): string {
return TypeScript.getDiagnosticMessage(this._diagnosticKey, this._arguments);
}
/**
* If a derived class has additional information about other referenced symbols, it can
* expose the locations of those symbols in a general way, so they can be reported along
* with the error.
*/
public additionalLocations(): Location[] {
return this._additionalLocations || [];
}
public static equals(diagnostic1: Diagnostic, diagnostic2: Diagnostic): boolean {
return Location.equals(diagnostic1, diagnostic2) &&
diagnostic1._diagnosticKey === diagnostic2._diagnosticKey &&
ArrayUtilities.sequenceEquals(diagnostic1._arguments, diagnostic2._arguments, (v1, v2) => v1 === v2);
}
public info(): DiagnosticInfo {
return getDiagnosticInfoFromKey(this.diagnosticKey());
}
}
export function newLine(): string {
// TODO: We need to expose an extensibility point on our hosts to have them tell us what
// they want the newline string to be. That way we can get the correct result regardless
// of which host we use
return "\r\n";
}
function getLargestIndex(diagnostic: string): number {
var largest = -1;
var regex = /\{(\d+)\}/g;
var match: RegExpExecArray;
while (match = regex.exec(diagnostic)) {
var val = parseInt(match[1]);
if (!isNaN(val) && val > largest) {
largest = val;
}
}
return largest;
}
function getDiagnosticInfoFromKey(diagnosticKey: string): DiagnosticInfo {
var result: DiagnosticInfo = diagnosticInformationMap[diagnosticKey];
Debug.assert(result);
return result;
}
export function getLocalizedText(diagnosticKey: string, args: any[]): string {
var diagnosticMessageText: string = diagnosticKey;
Debug.assert(diagnosticMessageText !== undefined && diagnosticMessageText !== null);
var actualCount = args ? args.length : 0;
// We have a string like "foo_0_bar_1". We want to find the largest integer there.
// (i.e.'1'). We then need one more arg than that to be correct.
var expectedCount = 1 + getLargestIndex(diagnosticKey);
if (expectedCount !== actualCount) {
throw new Error(getLocalizedText(DiagnosticCode.Expected_0_arguments_to_message_got_1_instead, [expectedCount, actualCount]));
}
// This should also be the same number of arguments as the message text
var valueCount = 1 + getLargestIndex(diagnosticMessageText);
if (valueCount !== expectedCount) {
throw new Error(getLocalizedText(DiagnosticCode.Expected_the_message_0_to_have_1_arguments_but_it_had_2, [diagnosticMessageText, expectedCount, valueCount]));
}
diagnosticMessageText = diagnosticMessageText.replace(/{(\d+)}/g, function (match, num?) {
return typeof args[num] !== 'undefined'
? args[num]
: match;
});
diagnosticMessageText = diagnosticMessageText.replace(/{(NL)}/g, function (match) {
return TypeScript.newLine();
});
return diagnosticMessageText;
}
export function getDiagnosticMessage(diagnosticKey: string, args: any[]): string {
var diagnostic = getDiagnosticInfoFromKey(diagnosticKey);
var diagnosticMessageText = getLocalizedText(diagnosticKey, args);
var message: string;
if (diagnostic.category === DiagnosticCategory.Error) {
message = getLocalizedText(DiagnosticCode.error_TS_0_1, [diagnostic.code, diagnosticMessageText]);
}
else if (diagnostic.category === DiagnosticCategory.Warning) {
message = getLocalizedText(DiagnosticCode.warning_TS_0_1, [diagnostic.code, diagnosticMessageText]);
}
else {
message = diagnosticMessageText;
}
return message;
}
}

View file

@ -1,9 +0,0 @@
///<reference path='references.ts' />
module TypeScript {
export interface DiagnosticInfo {
category: DiagnosticCategory;
message: string;
code: number;
}
}

View file

@ -1,29 +0,0 @@
///<reference path='references.ts' />
module TypeScript {
export class Errors {
public static argument(argument: string, message?: string): Error {
return new Error("Invalid argument: " + argument + ". " + message);
}
public static argumentOutOfRange(argument: string): Error {
return new Error("Argument out of range: " + argument);
}
public static argumentNull(argument: string): Error {
return new Error("Argument null: " + argument);
}
public static abstract(): Error {
return new Error("Operation not implemented properly by subclass.");
}
public static notYetImplemented(): Error {
return new Error("Not yet implemented.");
}
public static invalidOperation(message?: string): Error {
return new Error("Invalid operation: " + message);
}
}
}

View file

@ -1,22 +0,0 @@
///<reference path='references.ts' />
module TypeScript {
export module IntegerUtilities {
export function integerDivide(numerator: number, denominator: number): number {
return (numerator / denominator) >> 0;
}
export function integerMultiplyLow32Bits(n1: number, n2: number): number {
var resultLow32 = (((n1 & 0xffff0000) * n2) >>> 0) + (((n1 & 0x0000ffff) * n2) >>> 0) >>> 0;
return resultLow32;
}
export function isInteger(text: string): boolean {
return /^[0-9]+$/.test(text);
}
export function isHexInteger(text: string): boolean {
return /^0(x|X)[0-9a-fA-F]+$/.test(text);
}
}
}

View file

@ -1,87 +0,0 @@
///<reference path='references.ts' />
module TypeScript {
export interface ILineAndCharacter {
line: number;
character: number;
}
export class LineMap {
public static empty = new LineMap(() => [0], 0);
private _lineStarts: number[] = undefined;
constructor(private _computeLineStarts: () => number[], private length: number) {
}
public toJSON(key: any) {
return { lineStarts: this.lineStarts(), length: this.length };
}
public equals(other: LineMap): boolean {
return this.length === other.length &&
ArrayUtilities.sequenceEquals(this.lineStarts(), other.lineStarts(), (v1, v2) => v1 === v2);
}
public lineStarts(): number[] {
if (!this._lineStarts) {
this._lineStarts = this._computeLineStarts();
}
return this._lineStarts;
}
public lineCount(): number {
return this.lineStarts().length;
}
public getPosition(line: number, character: number): number {
return this.lineStarts()[line] + character;
}
public getLineNumberFromPosition(position: number): number {
if (position < 0 || position > this.length) {
throw Errors.argumentOutOfRange("position");
}
if (position === this.length) {
// this can happen when the user tried to get the line of items
// that are at the absolute end of this text (i.e. the EndOfLine
// token, or missing tokens that are at the end of the text).
// In this case, we want the last line in the text.
return this.lineCount() - 1;
}
// Binary search to find the right line
var lineNumber = ArrayUtilities.binarySearch(this.lineStarts(), position);
if (lineNumber < 0) {
lineNumber = (~lineNumber) - 1;
}
return lineNumber;
}
public getLineStartPosition(lineNumber: number): number {
return this.lineStarts()[lineNumber];
}
public fillLineAndCharacterFromPosition(position: number, lineAndCharacter: ILineAndCharacter): void {
if (position < 0 || position > this.length) {
throw Errors.argumentOutOfRange("position");
}
var lineNumber = this.getLineNumberFromPosition(position);
lineAndCharacter.line = lineNumber;
lineAndCharacter.character = position - this.lineStarts()[lineNumber];
}
public getLineAndCharacterFromPosition(position: number): LineAndCharacter {
if (position < 0 || position > this.length) {
throw Errors.argumentOutOfRange("position");
}
var lineNumber = this.getLineNumberFromPosition(position);
return new LineAndCharacter(lineNumber, position - this.lineStarts()[lineNumber]);
}
}
}

View file

@ -1,35 +0,0 @@
///<reference path='references.ts' />
module TypeScript {
export class LineAndCharacter {
private _line: number = 0;
private _character: number = 0;
/**
* Initializes a new instance of a LinePosition with the given line and character. ArgumentOutOfRangeException if "line" or "character" is less than zero.
* @param line The line of the line position. The first line in a file is defined as line 0 (zero based line numbering).
* @param character The character position in the line.
*/
constructor(line: number, character: number) {
if (line < 0) {
throw Errors.argumentOutOfRange("line");
}
if (character < 0) {
throw Errors.argumentOutOfRange("character");
}
this._line = line;
this._character = character;
}
public line(): number {
return this._line;
}
public character(): number {
return this._character;
}
}
}

View file

@ -1,13 +0,0 @@
///<reference path='references.ts' />
module TypeScript {
export class MathPrototype {
public static max(a: number, b: number): number {
return a >= b ? a : b;
}
public static min(a: number, b: number): number {
return a <= b ? a : b;
}
}
}

View file

@ -1,12 +0,0 @@
///<reference path='..\resources\references.ts' />
///<reference path='arrayUtilities.ts' />
///<reference path='debug.ts' />
///<reference path='diagnosticCategory.ts' />
///<reference path='diagnosticCore.ts' />
///<reference path='diagnosticInfo.ts' />
///<reference path='errors.ts' />
///<reference path='integerUtilities.ts' />
///<reference path='lineMap.ts' />
///<reference path='linePosition.ts' />
///<reference path='stringUtilities.ts' />

View file

@ -1,159 +0,0 @@
///<reference path='references.ts' />
module TypeScript.Collections {
export var DefaultStringTableCapacity = 256;
class StringTableEntry {
constructor(public Text: string,
public HashCode: number,
public Next: StringTableEntry) {
}
}
// A table of interned strings. Faster and better than an arbitrary hashtable for the needs of the
// scanner. Specifically, the scanner operates over a sliding window of characters, with a start
// and end pointer for the current lexeme. The scanner then wants to get the *interned* string
// represented by that subsection.
//
// Importantly, if the string is already interned, then it wants ask "is the string represented by
// this section of a char array contained within the table" in a non-allocating fashion. i.e. if
// you have "[' ', 'p', 'u', 'b', 'l', 'i', 'c', ' ']" and you ask to get the string represented by
// range [1, 7), then this table will return "public" without any allocations if that value was
// already in the table.
//
// Of course, if the value is not in the table then there will be an initial cost to allocate the
// string and the bucket for the table. However, that is only incurred the first time each unique
// string is added.
export class StringTable {
// TODO: uncomment this once typecheck bug is fixed.
private entries: StringTableEntry[];
private count: number = 0;
constructor(capacity: number) {
var size = Hash.getPrime(capacity);
this.entries = ArrayUtilities.createArray<StringTableEntry>(size, null);
}
public addCharArray(key: number[], start: number, len: number): string {
// Compute the hash for this key. Also ensure that it fits within 31 bits (so that it
// stays a non-heap integer, and so we can index into the array safely).
var hashCode = Hash.computeSimple31BitCharArrayHashCode(key, start, len) & 0x7FFFFFFF;
// Debug.assert(hashCode > 0);
// First see if we already have the string represented by "key[start, start + len)" already
// present in this table. If we do, just return that string. Do this without any
// allocations
var entry = this.findCharArrayEntry(key, start, len, hashCode);
if (entry !== null) {
return entry.Text;
}
// We don't have an entry for that string in our table. Convert that
var slice: number[] = key.slice(start, start + len);
return this.addEntry(StringUtilities.fromCharCodeArray(slice), hashCode);
}
private findCharArrayEntry(key: number[], start: number, len: number, hashCode: number) {
for (var e = this.entries[hashCode % this.entries.length]; e !== null; e = e.Next) {
if (e.HashCode === hashCode && StringTable.textCharArrayEquals(e.Text, key, start, len)) {
return e;
}
}
return null;
}
private addEntry(text: string, hashCode: number): string {
var index = hashCode % this.entries.length;
var e = new StringTableEntry(text, hashCode, this.entries[index]);
this.entries[index] = e;
// We grow when our load factor equals 1. I tried different load factors (like .75 and
// .5), however they seemed to have no effect on running time. With a load factor of 1
// we seem to get about 80% slot fill rate with an average of around 1.25 table entries
// per slot.
if (this.count === this.entries.length) {
this.grow();
}
this.count++;
return e.Text;
}
//private dumpStats() {
// var standardOut = Environment.standardOut;
// standardOut.WriteLine("----------------------")
// standardOut.WriteLine("String table stats");
// standardOut.WriteLine("Count : " + this.count);
// standardOut.WriteLine("Entries Length : " + this.entries.length);
// var longestSlot = 0;
// var occupiedSlots = 0;
// for (var i = 0; i < this.entries.length; i++) {
// if (this.entries[i] !== null) {
// occupiedSlots++;
// var current = this.entries[i];
// var slotCount = 0;
// while (current !== null) {
// slotCount++;
// current = current.Next;
// }
// longestSlot = MathPrototype.max(longestSlot, slotCount);
// }
// }
// standardOut.WriteLine("Occupied slots : " + occupiedSlots);
// standardOut.WriteLine("Longest slot : " + longestSlot);
// standardOut.WriteLine("Avg Length/Slot : " + (this.count / occupiedSlots));
// standardOut.WriteLine("----------------------");
//}
private grow(): void {
// this.dumpStats();
var newSize = Hash.expandPrime(this.entries.length);
var oldEntries = this.entries;
var newEntries: StringTableEntry[] = ArrayUtilities.createArray<StringTableEntry>(newSize, null);
this.entries = newEntries;
for (var i = 0; i < oldEntries.length; i++) {
var e = oldEntries[i];
while (e !== null) {
var newIndex = e.HashCode % newSize;
var tmp = e.Next;
e.Next = newEntries[newIndex];
newEntries[newIndex] = e;
e = tmp;
}
}
// this.dumpStats();
}
private static textCharArrayEquals(text: string, array: number[], start: number, length: number): boolean {
if (text.length !== length) {
return false;
}
var s = start;
for (var i = 0; i < length; i++) {
if (text.charCodeAt(i) !== array[s]) {
return false;
}
s++;
}
return true;
}
}
export var DefaultStringTable = new StringTable(DefaultStringTableCapacity);
}

View file

@ -1,21 +0,0 @@
///<reference path='references.ts' />
module TypeScript {
export class StringUtilities {
public static isString(value: any): boolean {
return Object.prototype.toString.apply(value, []) === '[object String]';
}
public static endsWith(string: string, value: string): boolean {
return string.substring(string.length - value.length, string.length) === value;
}
public static startsWith(string: string, value: string): boolean {
return string.substr(0, value.length) === value;
}
public static repeat(value: string, count: number) {
return Array(count + 1).join(value);
}
}
}

View file

@ -1,448 +0,0 @@
// <auto-generated />
module TypeScript {
export var DiagnosticCode = {
error_TS_0_1: "error TS{0}: {1}",
warning_TS_0_1: "warning TS{0}: {1}",
Unrecognized_escape_sequence: "Unrecognized escape sequence.",
Unexpected_character_0: "Unexpected character {0}.",
Unterminated_string_literal: "Unterminated string literal.",
Identifier_expected: "Identifier expected.",
_0_keyword_expected: "'{0}' keyword expected.",
_0_expected: "'{0}' expected.",
Identifier_expected_0_is_a_keyword: "Identifier expected; '{0}' is a keyword.",
Automatic_semicolon_insertion_not_allowed: "Automatic semicolon insertion not allowed.",
Unexpected_token_0_expected: "Unexpected token; '{0}' expected.",
Trailing_comma_not_allowed: "Trailing comma not allowed.",
public_or_private_modifier_must_precede_static: "'public' or 'private' modifier must precede 'static'.",
Unexpected_token: "Unexpected token.",
Catch_clause_parameter_cannot_have_a_type_annotation: "Catch clause parameter cannot have a type annotation.",
A_rest_parameter_must_be_last_in_a_parameter_list: "A rest parameter must be last in a parameter list.",
Parameter_cannot_have_question_mark_and_initializer: "Parameter cannot have question mark and initializer.",
A_required_parameter_cannot_follow_an_optional_parameter: "A required parameter cannot follow an optional parameter.",
Index_signatures_cannot_have_rest_parameters: "Index signatures cannot have rest parameters.",
Index_signature_parameter_cannot_have_modifiers: "Index signature parameter cannot have modifiers.",
Index_signature_parameter_cannot_have_a_question_mark: "Index signature parameter cannot have a question mark.",
Index_signature_parameter_cannot_have_an_initializer: "Index signature parameter cannot have an initializer.",
Index_signature_must_have_a_type_annotation: "Index signature must have a type annotation.",
Index_signature_parameter_must_have_a_type_annotation: "Index signature parameter must have a type annotation.",
Index_signature_parameter_type_must_be_string_or_number: "Index signature parameter type must be 'string' or 'number'.",
extends_clause_already_seen: "'extends' clause already seen.",
extends_clause_must_precede_implements_clause: "'extends' clause must precede 'implements' clause.",
Classes_can_only_extend_a_single_class: "Classes can only extend a single class.",
implements_clause_already_seen: "'implements' clause already seen.",
Accessibility_modifier_already_seen: "Accessibility modifier already seen.",
_0_modifier_must_precede_1_modifier: "'{0}' modifier must precede '{1}' modifier.",
_0_modifier_already_seen: "'{0}' modifier already seen.",
_0_modifier_cannot_appear_on_a_class_element: "'{0}' modifier cannot appear on a class element.",
Interface_declaration_cannot_have_implements_clause: "Interface declaration cannot have 'implements' clause.",
super_invocation_cannot_have_type_arguments: "'super' invocation cannot have type arguments.",
Only_ambient_modules_can_use_quoted_names: "Only ambient modules can use quoted names.",
Statements_are_not_allowed_in_ambient_contexts: "Statements are not allowed in ambient contexts.",
A_function_implementation_cannot_be_declared_in_an_ambient_context: "A function implementation cannot be declared in an ambient context.",
A_declare_modifier_cannot_be_used_in_an_already_ambient_context: "A 'declare' modifier cannot be used in an already ambient context.",
Initializers_are_not_allowed_in_ambient_contexts: "Initializers are not allowed in ambient contexts.",
_0_modifier_cannot_appear_on_a_module_element: "'{0}' modifier cannot appear on a module element.",
A_declare_modifier_cannot_be_used_with_an_interface_declaration: "A 'declare' modifier cannot be used with an interface declaration.",
A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file: "A 'declare' modifier is required for a top level declaration in a .d.ts file.",
A_rest_parameter_cannot_be_optional: "A rest parameter cannot be optional.",
A_rest_parameter_cannot_have_an_initializer: "A rest parameter cannot have an initializer.",
set_accessor_must_have_exactly_one_parameter: "'set' accessor must have exactly one parameter.",
set_accessor_parameter_cannot_be_optional: "'set' accessor parameter cannot be optional.",
set_accessor_parameter_cannot_have_an_initializer: "'set' accessor parameter cannot have an initializer.",
set_accessor_cannot_have_rest_parameter: "'set' accessor cannot have rest parameter.",
get_accessor_cannot_have_parameters: "'get' accessor cannot have parameters.",
Modifiers_cannot_appear_here: "Modifiers cannot appear here.",
Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: "Accessors are only available when targeting ECMAScript 5 and higher.",
Enum_member_must_have_initializer: "Enum member must have initializer.",
Export_assignment_cannot_be_used_in_internal_modules: "Export assignment cannot be used in internal modules.",
Ambient_enum_elements_can_only_have_integer_literal_initializers: "Ambient enum elements can only have integer literal initializers.",
module_class_interface_enum_import_or_statement: "module, class, interface, enum, import or statement",
constructor_function_accessor_or_variable: "constructor, function, accessor or variable",
statement: "statement",
case_or_default_clause: "case or default clause",
identifier: "identifier",
call_construct_index_property_or_function_signature: "call, construct, index, property or function signature",
expression: "expression",
type_name: "type name",
property_or_accessor: "property or accessor",
parameter: "parameter",
type: "type",
type_parameter: "type parameter",
A_declare_modifier_cannot_be_used_with_an_import_declaration: "A 'declare' modifier cannot be used with an import declaration.",
Invalid_reference_directive_syntax: "Invalid 'reference' directive syntax.",
Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher: "Octal literals are not available when targeting ECMAScript 5 and higher.",
Accessors_are_not_allowed_in_ambient_contexts: "Accessors are not allowed in ambient contexts.",
_0_modifier_cannot_appear_on_a_constructor_declaration: "'{0}' modifier cannot appear on a constructor declaration.",
_0_modifier_cannot_appear_on_a_parameter: "'{0}' modifier cannot appear on a parameter.",
Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: "Only a single variable declaration is allowed in a 'for...in' statement.",
Type_parameters_cannot_appear_on_a_constructor_declaration: "Type parameters cannot appear on a constructor declaration.",
Type_annotation_cannot_appear_on_a_constructor_declaration: "Type annotation cannot appear on a constructor declaration.",
Type_parameters_cannot_appear_on_an_accessor: "Type parameters cannot appear on an accessor.",
Type_annotation_cannot_appear_on_a_set_accessor: "Type annotation cannot appear on a 'set' accessor.",
Index_signature_must_have_exactly_one_parameter: "Index signature must have exactly one parameter.",
_0_list_cannot_be_empty: "'{0}' list cannot be empty.",
variable_declaration: "variable declaration",
type_argument: "type argument",
Invalid_use_of_0_in_strict_mode: "Invalid use of '{0}' in strict mode.",
with_statements_are_not_allowed_in_strict_mode: "'with' statements are not allowed in strict mode.",
delete_cannot_be_called_on_an_identifier_in_strict_mode: "'delete' cannot be called on an identifier in strict mode.",
Invalid_left_hand_side_in_for_in_statement: "Invalid left-hand side in 'for...in' statement.",
continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: "'continue' statement can only be used within an enclosing iteration statement.",
break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: "'break' statement can only be used within an enclosing iteration or switch statement.",
Jump_target_not_found: "Jump target not found.",
Jump_target_cannot_cross_function_boundary: "Jump target cannot cross function boundary.",
return_statement_must_be_contained_within_a_function_body: "'return' statement must be contained within a function body.",
Expression_expected: "Expression expected.",
Type_expected: "Type expected.",
Template_literal_cannot_be_used_as_an_element_name: "Template literal cannot be used as an element name.",
Computed_property_names_cannot_be_used_here: "Computed property names cannot be used here.",
yield_expression_must_be_contained_within_a_generator_declaration: "'yield' expression must be contained within a generator declaration.",
Unterminated_regular_expression_literal: "Unterminated regular expression literal.",
Unterminated_template_literal: "Unterminated template literal.",
await_expression_must_be_contained_within_an_async_declaration: "'await' expression must be contained within an async declaration.",
async_arrow_function_parameters_must_be_parenthesized: "'async' arrow function parameters must be parenthesized.",
A_generator_declaration_cannot_have_the_async_modifier: "A generator declaration cannot have the 'async' modifier.",
async_modifier_cannot_appear_here: "'async' modifier cannot appear here.",
comma_expression_cannot_appear_in_a_computed_property_name: "'comma' expression cannot appear in a computed property name.",
String_literal_expected: "String literal expected.",
Duplicate_identifier_0: "Duplicate identifier '{0}'.",
The_name_0_does_not_exist_in_the_current_scope: "The name '{0}' does not exist in the current scope.",
The_name_0_does_not_refer_to_a_value: "The name '{0}' does not refer to a value.",
super_can_only_be_used_inside_a_class_instance_method: "'super' can only be used inside a class instance method.",
The_left_hand_side_of_an_assignment_expression_must_be_a_variable_property_or_indexer: "The left-hand side of an assignment expression must be a variable, property or indexer.",
Value_of_type_0_is_not_callable_Did_you_mean_to_include_new: "Value of type '{0}' is not callable. Did you mean to include 'new'?",
Value_of_type_0_is_not_callable: "Value of type '{0}' is not callable.",
Value_of_type_0_is_not_newable: "Value of type '{0}' is not newable.",
An_index_expression_argument_must_be_string_number_or_any: "An index expression argument must be 'string', 'number', or 'any'.",
Operator_0_cannot_be_applied_to_types_1_and_2: "Operator '{0}' cannot be applied to types '{1}' and '{2}'.",
Type_0_is_not_assignable_to_type_1: "Type '{0}' is not assignable to type '{1}'.",
Type_0_is_not_assignable_to_type_1_NL_2: "Type '{0}' is not assignable to type '{1}':{NL}{2}",
Expected_var_class_interface_or_module: "Expected var, class, interface, or module.",
Getter_0_already_declared: "Getter '{0}' already declared.",
Setter_0_already_declared: "Setter '{0}' already declared.",
Exported_class_0_extends_private_class_1: "Exported class '{0}' extends private class '{1}'.",
Exported_class_0_implements_private_interface_1: "Exported class '{0}' implements private interface '{1}'.",
Exported_interface_0_extends_private_interface_1: "Exported interface '{0}' extends private interface '{1}'.",
Exported_class_0_extends_class_from_inaccessible_module_1: "Exported class '{0}' extends class from inaccessible module {1}.",
Exported_class_0_implements_interface_from_inaccessible_module_1: "Exported class '{0}' implements interface from inaccessible module {1}.",
Exported_interface_0_extends_interface_from_inaccessible_module_1: "Exported interface '{0}' extends interface from inaccessible module {1}.",
Public_static_property_0_of_exported_class_has_or_is_using_private_type_1: "Public static property '{0}' of exported class has or is using private type '{1}'.",
Public_property_0_of_exported_class_has_or_is_using_private_type_1: "Public property '{0}' of exported class has or is using private type '{1}'.",
Property_0_of_exported_interface_has_or_is_using_private_type_1: "Property '{0}' of exported interface has or is using private type '{1}'.",
Exported_variable_0_has_or_is_using_private_type_1: "Exported variable '{0}' has or is using private type '{1}'.",
Public_static_property_0_of_exported_class_is_using_inaccessible_module_1: "Public static property '{0}' of exported class is using inaccessible module {1}.",
Public_property_0_of_exported_class_is_using_inaccessible_module_1: "Public property '{0}' of exported class is using inaccessible module {1}.",
Property_0_of_exported_interface_is_using_inaccessible_module_1: "Property '{0}' of exported interface is using inaccessible module {1}.",
Exported_variable_0_is_using_inaccessible_module_1: "Exported variable '{0}' is using inaccessible module {1}.",
Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of constructor from exported class has or is using private type '{1}'.",
Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of public static property setter from exported class has or is using private type '{1}'.",
Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of public property setter from exported class has or is using private type '{1}'.",
Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_1: "Parameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.",
Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_type_1: "Parameter '{0}' of call signature from exported interface has or is using private type '{1}'.",
Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of public static method from exported class has or is using private type '{1}'.",
Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of public method from exported class has or is using private type '{1}'.",
Parameter_0_of_method_from_exported_interface_has_or_is_using_private_type_1: "Parameter '{0}' of method from exported interface has or is using private type '{1}'.",
Parameter_0_of_exported_function_has_or_is_using_private_type_1: "Parameter '{0}' of exported function has or is using private type '{1}'.",
Parameter_0_of_constructor_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of constructor from exported class is using inaccessible module {1}.",
Parameter_0_of_public_static_property_setter_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of public static property setter from exported class is using inaccessible module {1}.",
Parameter_0_of_public_property_setter_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of public property setter from exported class is using inaccessible module {1}.",
Parameter_0_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_1: "Parameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.",
Parameter_0_of_call_signature_from_exported_interface_is_using_inaccessible_module_1: "Parameter '{0}' of call signature from exported interface is using inaccessible module {1}",
Parameter_0_of_public_static_method_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of public static method from exported class is using inaccessible module {1}.",
Parameter_0_of_public_method_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of public method from exported class is using inaccessible module {1}.",
Parameter_0_of_method_from_exported_interface_is_using_inaccessible_module_1: "Parameter '{0}' of method from exported interface is using inaccessible module {1}.",
Parameter_0_of_exported_function_is_using_inaccessible_module_1: "Parameter '{0}' of exported function is using inaccessible module {1}.",
Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_type_0: "Return type of public static property getter from exported class has or is using private type '{0}'.",
Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_type_0: "Return type of public property getter from exported class has or is using private type '{0}'.",
Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_0: "Return type of constructor signature from exported interface has or is using private type '{0}'.",
Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_type_0: "Return type of call signature from exported interface has or is using private type '{0}'.",
Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_type_0: "Return type of index signature from exported interface has or is using private type '{0}'.",
Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_type_0: "Return type of public static method from exported class has or is using private type '{0}'.",
Return_type_of_public_method_from_exported_class_has_or_is_using_private_type_0: "Return type of public method from exported class has or is using private type '{0}'.",
Return_type_of_method_from_exported_interface_has_or_is_using_private_type_0: "Return type of method from exported interface has or is using private type '{0}'.",
Return_type_of_exported_function_has_or_is_using_private_type_0: "Return type of exported function has or is using private type '{0}'.",
Return_type_of_public_static_property_getter_from_exported_class_is_using_inaccessible_module_0: "Return type of public static property getter from exported class is using inaccessible module {0}.",
Return_type_of_public_property_getter_from_exported_class_is_using_inaccessible_module_0: "Return type of public property getter from exported class is using inaccessible module {0}.",
Return_type_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_0: "Return type of constructor signature from exported interface is using inaccessible module {0}.",
Return_type_of_call_signature_from_exported_interface_is_using_inaccessible_module_0: "Return type of call signature from exported interface is using inaccessible module {0}.",
Return_type_of_index_signature_from_exported_interface_is_using_inaccessible_module_0: "Return type of index signature from exported interface is using inaccessible module {0}.",
Return_type_of_public_static_method_from_exported_class_is_using_inaccessible_module_0: "Return type of public static method from exported class is using inaccessible module {0}.",
Return_type_of_public_method_from_exported_class_is_using_inaccessible_module_0: "Return type of public method from exported class is using inaccessible module {0}.",
Return_type_of_method_from_exported_interface_is_using_inaccessible_module_0: "Return type of method from exported interface is using inaccessible module {0}.",
Return_type_of_exported_function_is_using_inaccessible_module_0: "Return type of exported function is using inaccessible module {0}.",
new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: "'new T[]' cannot be used to create an array. Use 'new Array<T>()' instead.",
A_parameter_list_must_follow_a_generic_type_argument_list_expected: "A parameter list must follow a generic type argument list. '(' expected.",
Multiple_constructor_implementations_are_not_allowed: "Multiple constructor implementations are not allowed.",
Cannot_find_external_module_0: "Cannot find external module '{0}'.",
Module_cannot_be_aliased_to_a_non_module_type: "Module cannot be aliased to a non-module type.",
A_class_may_only_extend_another_class: "A class may only extend another class.",
A_class_may_only_implement_another_class_or_interface: "A class may only implement another class or interface.",
An_interface_may_only_extend_a_class_or_another_interface: "An interface may only extend a class or another interface.",
Unable_to_resolve_type: "Unable to resolve type.",
Unable_to_resolve_type_of_0: "Unable to resolve type of '{0}'.",
Unable_to_resolve_type_parameter_constraint: "Unable to resolve type parameter constraint.",
Type_parameter_constraint_cannot_be_a_primitive_type: "Type parameter constraint cannot be a primitive type.",
Supplied_parameters_do_not_match_any_signature_of_call_target: "Supplied parameters do not match any signature of call target.",
Supplied_parameters_do_not_match_any_signature_of_call_target_NL_0: "Supplied parameters do not match any signature of call target:{NL}{0}",
Cannot_use_new_with_an_expression_whose_type_lacks_a_signature: "Cannot use 'new' with an expression whose type lacks a signature.",
Only_a_void_function_can_be_called_with_the_new_keyword: "Only a void function can be called with the 'new' keyword.",
Could_not_select_overload_for_new_expression: "Could not select overload for 'new' expression.",
Type_0_does_not_satisfy_the_constraint_1: "Type '{0}' does not satisfy the constraint '{1}'.",
Could_not_select_overload_for_call_expression: "Could not select overload for 'call' expression.",
Cannot_invoke_an_expression_whose_type_lacks_a_call_signature: "Cannot invoke an expression whose type lacks a call signature.",
Calls_to_super_are_only_valid_inside_a_class: "Calls to 'super' are only valid inside a class.",
Generic_type_0_requires_1_type_argument_s: "Generic type '{0}' requires {1} type argument(s).",
Type_of_array_literal_cannot_be_determined_Best_common_type_could_not_be_found_for_array_elements: "Type of array literal cannot be determined. Best common type could not be found for array elements.",
Could_not_find_enclosing_symbol_for_dotted_name_0: "Could not find enclosing symbol for dotted name '{0}'.",
Property_0_does_not_exist_on_value_of_type_1: "Property '{0}' does not exist on value of type '{1}'.",
Cannot_find_name_0: "Cannot find name '{0}'.",
get_and_set_accessor_must_have_the_same_type: "'get' and 'set' accessor must have the same type.",
this_cannot_be_referenced_in_current_location: "'this' cannot be referenced in current location.",
Static_members_cannot_reference_class_type_parameters: "Static members cannot reference class type parameters.",
Type_0_recursively_references_itself_as_a_base_type: "Type '{0}' recursively references itself as a base type.",
super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class: "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.",
super_can_only_be_referenced_in_a_derived_class: "'super' can only be referenced in a derived class.",
A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties: "A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties.",
Constructors_for_derived_classes_must_contain_a_super_call: "Constructors for derived classes must contain a 'super' call.",
Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: "Super calls are not permitted outside constructors or in nested functions inside constructors.",
_0_1_is_inaccessible: "'{0}.{1}' is inaccessible.",
this_cannot_be_referenced_in_a_module_body: "'this' cannot be referenced in a module body.",
Invalid_expression_types_not_known_to_support_the_addition_operator: "Invalid '+' expression - types not known to support the addition operator.",
The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.",
The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.",
An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: "An arithmetic operand must be of type 'any', 'number' or an enum type.",
Variable_declarations_of_a_for_statement_cannot_use_a_type_annotation: "Variable declarations of a 'for' statement cannot use a type annotation.",
Variable_declarations_of_a_for_statement_must_be_of_types_string_or_any: "Variable declarations of a 'for' statement must be of types 'string' or 'any'.",
The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter: "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter.",
The_left_hand_side_of_an_in_expression_must_be_of_types_any_string_or_number: "The left-hand side of an 'in' expression must be of types 'any', 'string' or 'number'.",
The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter.",
The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.",
The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type.",
Setters_cannot_return_a_value: "Setters cannot return a value.",
Tried_to_query_type_of_uninitialized_module_0: "Tried to query type of uninitialized module '{0}'.",
Tried_to_set_variable_type_to_uninitialized_module_type_0: "Tried to set variable type to uninitialized module type '{0}'.",
Type_0_is_not_generic: "Type '{0}' is not generic.",
Getters_must_return_a_value: "Getters must return a value.",
Getter_and_setter_accessors_do_not_agree_in_visibility: "Getter and setter accessors do not agree in visibility.",
Invalid_left_hand_side_of_assignment_expression: "Invalid left-hand side of assignment expression.",
Function_declared_a_non_void_return_type_but_has_no_return_expression: "Function declared a non-void return type, but has no return expression.",
Cannot_resolve_return_type_reference: "Cannot resolve return type reference.",
Constructors_cannot_have_a_return_type_of_void: "Constructors cannot have a return type of 'void'.",
Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2: "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'.",
All_symbols_within_a_with_block_will_be_resolved_to_any: "All symbols within a with block will be resolved to 'any'.",
Import_declarations_in_an_internal_module_cannot_reference_an_external_module: "Import declarations in an internal module cannot reference an external module.",
Class_0_declares_interface_1_but_does_not_implement_it_NL_2: "Class {0} declares interface {1} but does not implement it:{NL}{2}",
Class_0_declares_class_1_as_an_interface_but_does_not_implement_it_NL_2: "Class {0} declares class {1} as an interface but does not implement it:{NL}{2}",
The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer: "The operand of an increment or decrement operator must be a variable, property or indexer.",
this_cannot_be_referenced_in_a_static_property_initializer: "'this' cannot be referenced in a static property initializer.",
Class_0_cannot_extend_class_1_NL_2: "Class '{0}' cannot extend class '{1}':{NL}{2}",
Interface_0_cannot_extend_class_1_NL_2: "Interface '{0}' cannot extend class '{1}':{NL}{2}",
Interface_0_cannot_extend_interface_1_NL_2: "Interface '{0}' cannot extend interface '{1}':{NL}{2}",
Overload_signature_is_not_compatible_with_function_definition: "Overload signature is not compatible with function definition.",
Overload_signature_is_not_compatible_with_function_definition_NL_0: "Overload signature is not compatible with function definition:{NL}{0}",
Overload_signatures_must_all_be_public_or_private: "Overload signatures must all be public or private.",
Overload_signatures_must_all_be_exported_or_not_exported: "Overload signatures must all be exported or not exported.",
Overload_signatures_must_all_be_ambient_or_non_ambient: "Overload signatures must all be ambient or non-ambient.",
Overload_signatures_must_all_be_optional_or_required: "Overload signatures must all be optional or required.",
Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature: "Specialized overload signature is not assignable to any non-specialized signature.",
this_cannot_be_referenced_in_constructor_arguments: "'this' cannot be referenced in constructor arguments.",
Instance_member_cannot_be_accessed_off_a_class: "Instance member cannot be accessed off a class.",
Untyped_function_calls_may_not_accept_type_arguments: "Untyped function calls may not accept type arguments.",
Non_generic_functions_may_not_accept_type_arguments: "Non-generic functions may not accept type arguments.",
A_generic_type_may_not_reference_itself_with_a_wrapped_form_of_its_own_type_parameters: "A generic type may not reference itself with a wrapped form of its own type parameters.",
A_rest_parameter_must_be_of_an_array_type: "A rest parameter must be of an array type.",
Overload_signature_implementation_cannot_use_specialized_type: "Overload signature implementation cannot use specialized type.",
Export_assignments_may_only_be_used_at_the_top_level_of_external_modules: "Export assignments may only be used at the top-level of external modules.",
Export_assignments_may_only_be_made_with_variables_functions_classes_interfaces_enums_and_internal_modules: "Export assignments may only be made with variables, functions, classes, interfaces, enums and internal modules.",
Only_public_methods_of_the_base_class_are_accessible_via_the_super_keyword: "Only public methods of the base class are accessible via the 'super' keyword.",
Numeric_indexer_type_0_must_be_assignable_to_string_indexer_type_1: "Numeric indexer type '{0}' must be assignable to string indexer type '{1}'.",
Numeric_indexer_type_0_must_be_assignable_to_string_indexer_type_1_NL_2: "Numeric indexer type '{0}' must be assignable to string indexer type '{1}':{NL}{2}",
All_numerically_named_properties_must_be_assignable_to_numeric_indexer_type_0: "All numerically named properties must be assignable to numeric indexer type '{0}'.",
All_numerically_named_properties_must_be_assignable_to_numeric_indexer_type_0_NL_1: "All numerically named properties must be assignable to numeric indexer type '{0}':{NL}{1}",
All_named_properties_must_be_assignable_to_string_indexer_type_0: "All named properties must be assignable to string indexer type '{0}'.",
All_named_properties_must_be_assignable_to_string_indexer_type_0_NL_1: "All named properties must be assignable to string indexer type '{0}':{NL}{1}",
A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation: "A parameter initializer is only allowed in a function or constructor implementation.",
Function_expression_declared_a_non_void_return_type_but_has_no_return_expression: "Function expression declared a non-void return type, but has no return expression.",
Import_declaration_referencing_identifier_from_internal_module_can_only_be_made_with_variables_functions_classes_interfaces_enums_and_internal_modules: "Import declaration referencing identifier from internal module can only be made with variables, functions, classes, interfaces, enums and internal modules.",
Module_0_has_no_exported_member_1: "Module '{0}' has no exported member '{1}'.",
Unable_to_resolve_module_reference_0: "Unable to resolve module reference '{0}'.",
Could_not_find_module_0_in_module_1: "Could not find module '{0}' in module '{1}'.",
Exported_import_declaration_0_is_assigned_value_with_type_that_has_or_is_using_private_type_1: "Exported import declaration '{0}' is assigned value with type that has or is using private type '{1}'.",
Exported_import_declaration_0_is_assigned_value_with_type_that_is_using_inaccessible_module_1: "Exported import declaration '{0}' is assigned value with type that is using inaccessible module '{1}'.",
Exported_import_declaration_0_is_assigned_type_that_has_or_is_using_private_type_1: "Exported import declaration '{0}' is assigned type that has or is using private type '{1}'.",
Exported_import_declaration_0_is_assigned_type_that_is_using_inaccessible_module_1: "Exported import declaration '{0}' is assigned type that is using inaccessible module '{1}'.",
Exported_import_declaration_0_is_assigned_container_that_is_or_is_using_inaccessible_module_1: "Exported import declaration '{0}' is assigned container that is or is using inaccessible module '{1}'.",
Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_1: "Type name '{0}' in extends clause does not reference constructor function for '{1}'.",
Internal_module_reference_0_in_import_declaration_does_not_reference_module_instance_for_1: "Internal module reference '{0}' in import declaration does not reference module instance for '{1}'.",
Module_0_cannot_merge_with_previous_declaration_of_1_in_a_different_file_2: "Module '{0}' cannot merge with previous declaration of '{1}' in a different file '{2}'.",
Interface_0_cannot_simultaneously_extend_types_1_and_2_NL_3: "Interface '{0}' cannot simultaneously extend types '{1}' and '{2}':{NL}{3}",
Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it: "Initializer of parameter '{0}' cannot reference identifier '{1}' declared after it.",
Ambient_external_module_declaration_cannot_be_reopened: "Ambient external module declaration cannot be reopened.",
All_declarations_of_merged_declaration_0_must_be_exported_or_not_exported: "All declarations of merged declaration '{0}' must be exported or not exported.",
super_cannot_be_referenced_in_constructor_arguments: "'super' cannot be referenced in constructor arguments.",
Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: "Return type of constructor signature must be assignable to the instance type of the class.",
Ambient_external_module_declaration_must_be_defined_in_global_context: "Ambient external module declaration must be defined in global context.",
Ambient_external_module_declaration_cannot_specify_relative_module_name: "Ambient external module declaration cannot specify relative module name.",
Import_declaration_in_an_ambient_external_module_declaration_cannot_reference_external_module_through_relative_external_module_name: "Import declaration in an ambient external module declaration cannot reference external module through relative external module name.",
No_best_common_type_exists_among_return_expressions: "No best common type exists among return expressions.",
Import_declaration_cannot_refer_to_external_module_reference_when_noResolve_option_is_set: "Import declaration cannot refer to external module reference when --noResolve option is set.",
Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference.",
Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference: "Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference.",
Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference.",
Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference: "Expression resolves to '_super' that compiler uses to capture base class reference.",
TypeParameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_1: "TypeParameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.",
TypeParameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_type_1: "TypeParameter '{0}' of call signature from exported interface has or is using private type '{1}'.",
TypeParameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_type_1: "TypeParameter '{0}' of public static method from exported class has or is using private type '{1}'.",
TypeParameter_0_of_public_method_from_exported_class_has_or_is_using_private_type_1: "TypeParameter '{0}' of public method from exported class has or is using private type '{1}'.",
TypeParameter_0_of_method_from_exported_interface_has_or_is_using_private_type_1: "TypeParameter '{0}' of method from exported interface has or is using private type '{1}'.",
TypeParameter_0_of_exported_function_has_or_is_using_private_type_1: "TypeParameter '{0}' of exported function has or is using private type '{1}'.",
TypeParameter_0_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_1: "TypeParameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.",
TypeParameter_0_of_call_signature_from_exported_interface_is_using_inaccessible_module_1: "TypeParameter '{0}' of call signature from exported interface is using inaccessible module {1}",
TypeParameter_0_of_public_static_method_from_exported_class_is_using_inaccessible_module_1: "TypeParameter '{0}' of public static method from exported class is using inaccessible module {1}.",
TypeParameter_0_of_public_method_from_exported_class_is_using_inaccessible_module_1: "TypeParameter '{0}' of public method from exported class is using inaccessible module {1}.",
TypeParameter_0_of_method_from_exported_interface_is_using_inaccessible_module_1: "TypeParameter '{0}' of method from exported interface is using inaccessible module {1}.",
TypeParameter_0_of_exported_function_is_using_inaccessible_module_1: "TypeParameter '{0}' of exported function is using inaccessible module {1}.",
TypeParameter_0_of_exported_class_has_or_is_using_private_type_1: "TypeParameter '{0}' of exported class has or is using private type '{1}'.",
TypeParameter_0_of_exported_interface_has_or_is_using_private_type_1: "TypeParameter '{0}' of exported interface has or is using private type '{1}'.",
TypeParameter_0_of_exported_class_is_using_inaccessible_module_1: "TypeParameter '{0}' of exported class is using inaccessible module {1}.",
TypeParameter_0_of_exported_interface_is_using_inaccessible_module_1: "TypeParameter '{0}' of exported interface is using inaccessible module {1}.",
Duplicate_identifier_i_Compiler_uses_i_to_initialize_rest_parameter: "Duplicate identifier '_i'. Compiler uses '_i' to initialize rest parameter.",
Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters.",
No_best_common_type_exists_between_0_and_1: "No best common type exists between '{0}' and '{1}'.",
No_best_common_type_exists_between_0_1_and_2: "No best common type exists between '{0}', '{1}', and '{2}'.",
Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_an_external_module: "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of an external module.",
Constraint_of_a_type_parameter_cannot_reference_any_type_parameter_from_the_same_type_parameter_list: "Constraint of a type parameter cannot reference any type parameter from the same type parameter list.",
Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor.",
Parameter_0_cannot_be_referenced_in_its_initializer: "Parameter '{0}' cannot be referenced in its initializer.",
Duplicate_string_index_signature: "Duplicate string index signature.",
Duplicate_number_index_signature: "Duplicate number index signature.",
All_declarations_of_an_interface_must_have_identical_type_parameters: "All declarations of an interface must have identical type parameters.",
Expression_resolves_to_variable_declaration_i_that_compiler_uses_to_initialize_rest_parameter: "Expression resolves to variable declaration '_i' that compiler uses to initialize rest parameter.",
Neither_type_0_nor_type_1_is_assignable_to_the_other: "Neither type '{0}' nor type '{1}' is assignable to the other.",
Neither_type_0_nor_type_1_is_assignable_to_the_other_NL_2: "Neither type '{0}' nor type '{1}' is assignable to the other:{NL}{2}",
Duplicate_function_implementation: "Duplicate function implementation.",
Function_implementation_expected: "Function implementation expected.",
Function_overload_name_must_be_0: "Function overload name must be '{0}'.",
Constructor_implementation_expected: "Constructor implementation expected.",
Class_name_cannot_be_0: "Class name cannot be '{0}'.",
Interface_name_cannot_be_0: "Interface name cannot be '{0}'.",
Enum_name_cannot_be_0: "Enum name cannot be '{0}'.",
A_module_cannot_have_multiple_export_assignments: "A module cannot have multiple export assignments.",
Export_assignment_not_allowed_in_module_with_exported_element: "Export assignment not allowed in module with exported element.",
A_parameter_property_is_only_allowed_in_a_constructor_implementation: "A parameter property is only allowed in a constructor implementation.",
Function_overload_must_be_static: "Function overload must be static.",
Function_overload_must_not_be_static: "Function overload must not be static.",
Type_0_is_missing_property_1_from_type_2: "Type '{0}' is missing property '{1}' from type '{2}'.",
Types_of_property_0_of_types_1_and_2_are_incompatible: "Types of property '{0}' of types '{1}' and '{2}' are incompatible.",
Types_of_property_0_of_types_1_and_2_are_incompatible_NL_3: "Types of property '{0}' of types '{1}' and '{2}' are incompatible:{NL}{3}",
Property_0_defined_as_private_in_type_1_is_defined_as_public_in_type_2: "Property '{0}' defined as private in type '{1}' is defined as public in type '{2}'.",
Property_0_defined_as_public_in_type_1_is_defined_as_private_in_type_2: "Property '{0}' defined as public in type '{1}' is defined as private in type '{2}'.",
Types_0_and_1_define_property_2_as_private: "Types '{0}' and '{1}' define property '{2}' as private.",
Call_signatures_of_types_0_and_1_are_incompatible: "Call signatures of types '{0}' and '{1}' are incompatible.",
Call_signatures_of_types_0_and_1_are_incompatible_NL_2: "Call signatures of types '{0}' and '{1}' are incompatible:{NL}{2}",
Type_0_requires_a_call_signature_but_type_1_lacks_one: "Type '{0}' requires a call signature, but type '{1}' lacks one.",
Construct_signatures_of_types_0_and_1_are_incompatible: "Construct signatures of types '{0}' and '{1}' are incompatible.",
Construct_signatures_of_types_0_and_1_are_incompatible_NL_2: "Construct signatures of types '{0}' and '{1}' are incompatible:{NL}{2}",
Type_0_requires_a_construct_signature_but_type_1_lacks_one: "Type '{0}' requires a construct signature, but type '{1}' lacks one.",
Index_signatures_of_types_0_and_1_are_incompatible: "Index signatures of types '{0}' and '{1}' are incompatible.",
Index_signatures_of_types_0_and_1_are_incompatible_NL_2: "Index signatures of types '{0}' and '{1}' are incompatible:{NL}{2}",
Call_signature_expects_0_or_fewer_parameters: "Call signature expects {0} or fewer parameters.",
Could_not_apply_type_0_to_argument_1_which_is_of_type_2: "Could not apply type '{0}' to argument {1} which is of type '{2}'.",
Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function: "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function.",
Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function: "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function.",
Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor.",
Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property.",
Types_of_static_property_0_of_class_1_and_class_2_are_incompatible: "Types of static property '{0}' of class '{1}' and class '{2}' are incompatible.",
Types_of_static_property_0_of_class_1_and_class_2_are_incompatible_NL_3: "Types of static property '{0}' of class '{1}' and class '{2}' are incompatible:{NL}{3}",
Type_reference_cannot_refer_to_container_0: "Type reference cannot refer to container '{0}'.",
Type_reference_must_refer_to_type: "Type reference must refer to type.",
In_enums_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_the_first_enum_element: "In enums with multiple declarations only one declaration can omit an initializer for the first enum element.",
_0_overload_s: " (+ {0} overload(s))",
Variable_declaration_cannot_have_the_same_name_as_an_import_declaration: "Variable declaration cannot have the same name as an import declaration.",
Signature_expected_0_type_arguments_got_1_instead: "Signature expected {0} type arguments, got {1} instead.",
Property_0_defined_as_optional_in_type_1_but_is_required_in_type_2: "Property '{0}' defined as optional in type '{1}', but is required in type '{2}'.",
Types_0_and_1_originating_in_infinitely_expanding_type_reference_do_not_refer_to_same_named_type: "Types '{0}' and '{1}' originating in infinitely expanding type reference do not refer to same named type.",
Types_0_and_1_originating_in_infinitely_expanding_type_reference_have_incompatible_type_arguments: "Types '{0}' and '{1}' originating in infinitely expanding type reference have incompatible type arguments.",
Types_0_and_1_originating_in_infinitely_expanding_type_reference_have_incompatible_type_arguments_NL_2: "Types '{0}' and '{1}' originating in infinitely expanding type reference have incompatible type arguments:{NL}{2}",
Named_properties_0_of_types_1_and_2_are_not_identical: "Named properties '{0}' of types '{1}' and '{2}' are not identical.",
Types_of_string_indexer_of_types_0_and_1_are_not_identical: "Types of string indexer of types '{0}' and '{1}' are not identical.",
Types_of_number_indexer_of_types_0_and_1_are_not_identical: "Types of number indexer of types '{0}' and '{1}' are not identical.",
Type_of_number_indexer_in_type_0_is_not_assignable_to_string_indexer_type_in_type_1_NL_2: "Type of number indexer in type '{0}' is not assignable to string indexer type in type '{1}'.{NL}{2}",
Type_of_property_0_in_type_1_is_not_assignable_to_string_indexer_type_in_type_2_NL_3: "Type of property '{0}' in type '{1}' is not assignable to string indexer type in type '{2}'.{NL}{3}",
Type_of_property_0_in_type_1_is_not_assignable_to_number_indexer_type_in_type_2_NL_3: "Type of property '{0}' in type '{1}' is not assignable to number indexer type in type '{2}'.{NL}{3}",
Static_property_0_defined_as_private_in_type_1_is_defined_as_public_in_type_2: "Static property '{0}' defined as private in type '{1}' is defined as public in type '{2}'.",
Static_property_0_defined_as_public_in_type_1_is_defined_as_private_in_type_2: "Static property '{0}' defined as public in type '{1}' is defined as private in type '{2}'.",
Types_0_and_1_define_static_property_2_as_private: "Types '{0}' and '{1}' define static property '{2}' as private.",
Current_host_does_not_support_0_option: "Current host does not support '{0}' option.",
ECMAScript_target_version_0_not_supported_Specify_a_valid_target_version_1_default_or_2: "ECMAScript target version '{0}' not supported. Specify a valid target version: '{1}' (default), or '{2}'",
Argument_for_0_option_must_be_1_or_2: "Argument for '{0}' option must be '{1}' or '{2}'",
Could_not_find_file_0: "Could not find file: '{0}'.",
A_file_cannot_have_a_reference_to_itself: "A file cannot have a reference to itself.",
Cannot_resolve_referenced_file_0: "Cannot resolve referenced file: '{0}'.",
Cannot_find_the_common_subdirectory_path_for_the_input_files: "Cannot find the common subdirectory path for the input files.",
Emit_Error_0: "Emit Error: {0}.",
Cannot_read_file_0_1: "Cannot read file '{0}': {1}",
Unsupported_file_encoding: "Unsupported file encoding.",
Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: "Locale must be of the form <language> or <language>-<territory>. For example '{0}' or '{1}'.",
Unsupported_locale_0: "Unsupported locale: '{0}'.",
Execution_Failed_NL: "Execution Failed.{NL}",
Invalid_call_to_up: "Invalid call to 'up'",
Invalid_call_to_down: "Invalid call to 'down'",
Base64_value_0_finished_with_a_continuation_bit: "Base64 value '{0}' finished with a continuation bit.",
Unknown_compiler_option_0: "Unknown compiler option '{0}'",
Expected_0_arguments_to_message_got_1_instead: "Expected {0} arguments to message, got {1} instead.",
Expected_the_message_0_to_have_1_arguments_but_it_had_2: "Expected the message '{0}' to have {1} arguments, but it had {2}",
Could_not_delete_file_0: "Could not delete file '{0}'",
Could_not_create_directory_0: "Could not create directory '{0}'",
Error_while_executing_file_0: "Error while executing file '{0}': ",
Cannot_compile_external_modules_unless_the_module_flag_is_provided: "Cannot compile external modules unless the '--module' flag is provided.",
Option_mapRoot_cannot_be_specified_without_specifying_sourcemap_option: "Option mapRoot cannot be specified without specifying sourcemap option.",
Option_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option: "Option sourceRoot cannot be specified without specifying sourcemap option.",
Options_mapRoot_and_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option: "Options mapRoot and sourceRoot cannot be specified without specifying sourcemap option.",
Option_0_specified_without_1: "Option '{0}' specified without '{1}'",
codepage_option_not_supported_on_current_platform: "'codepage' option not supported on current platform.",
Concatenate_and_emit_output_to_single_file: "Concatenate and emit output to single file.",
Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: "Specifies the location where debugger should locate map files instead of generated locations.",
Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations: "Specifies the location where debugger should locate TypeScript files instead of source locations.",
Watch_input_files: "Watch input files.",
Redirect_output_structure_to_the_directory: "Redirect output structure to the directory.",
Do_not_emit_comments_to_output: "Do not emit comments to output.",
Print_this_message: "Print this message.",
Allow_use_of_deprecated_0_keyword_when_referencing_an_external_module: "Allow use of deprecated '{0}' keyword when referencing an external module.",
Syntax_0: "Syntax: {0}",
options: "options",
file1: "file",
Examples: "Examples:",
Options: "Options:",
Insert_command_line_options_and_files_from_a_file: "Insert command line options and files from a file.",
Version_0: "Version {0}",
Use_the_0_flag_to_see_options: "Use the '{0}' flag to see options.",
NL_Recompiling_0: "{NL}Recompiling ({0}):",
STRING: "STRING",
KIND: "KIND",
file2: "FILE",
VERSION: "VERSION",
LOCATION: "LOCATION",
DIRECTORY: "DIRECTORY",
NUMBER: "NUMBER",
Additional_locations: "Additional locations:",
This_version_of_the_Javascript_runtime_does_not_support_the_0_function: "This version of the Javascript runtime does not support the '{0}' function.",
Unknown_rule: "Unknown rule.",
Invalid_line_number_0: "Invalid line number ({0})",
Raise_error_on_expressions_and_declarations_with_an_implied_any_type: "Raise error on expressions and declarations with an implied 'any' type.",
Variable_0_implicitly_has_an_any_type: "Variable '{0}' implicitly has an 'any' type.",
Parameter_0_of_1_implicitly_has_an_any_type: "Parameter '{0}' of '{1}' implicitly has an 'any' type.",
Parameter_0_of_function_type_implicitly_has_an_any_type: "Parameter '{0}' of function type implicitly has an 'any' type.",
Member_0_of_object_type_implicitly_has_an_any_type: "Member '{0}' of object type implicitly has an 'any' type.",
new_expression_which_lacks_a_constructor_signature_implicitly_has_an_any_type: "'new' expression, which lacks a constructor signature, implicitly has an 'any' type.",
_0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: "'{0}', which lacks return-type annotation, implicitly has an 'any' return type.",
Function_expression_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: "Function expression, which lacks return-type annotation, implicitly has an 'any' return type.",
Parameter_0_of_lambda_function_implicitly_has_an_any_type: "Parameter '{0}' of lambda function implicitly has an 'any' type.",
Constructor_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: "Constructor signature, which lacks return-type annotation, implicitly has an 'any' return type.",
Lambda_Function_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: "Lambda Function, which lacks return-type annotation, implicitly has an 'any' return type.",
Array_Literal_implicitly_has_an_any_type_from_widening: "Array Literal implicitly has an 'any' type from widening.",
_0_which_lacks_get_accessor_and_parameter_type_annotation_on_set_accessor_implicitly_has_an_any_type: "'{0}', which lacks 'get' accessor and parameter type annotation on 'set' accessor, implicitly has an 'any' type.",
Index_signature_of_object_type_implicitly_has_an_any_type: "Index signature of object type implicitly has an 'any' type.",
Object_literal_s_property_0_implicitly_has_an_any_type_from_widening: "Object literal's property '{0}' implicitly has an 'any' type from widening.",
};
}

View file

@ -1,457 +0,0 @@
// <auto-generated />
/// <reference path="..\core\diagnosticCategory.ts" />
module TypeScript {
export var diagnosticInformationMap: ts.Map<any> = {
"error TS{0}: {1}": { "code": 0, "category": DiagnosticCategory.NoPrefix },
"warning TS{0}: {1}": { "code": 1, "category": DiagnosticCategory.NoPrefix },
"Unrecognized escape sequence.": { "code": 1000, "category": DiagnosticCategory.Error },
"Unexpected character {0}.": { "code": 1001, "category": DiagnosticCategory.Error },
"Unterminated string literal.": { "code": 1002, "category": DiagnosticCategory.Error },
"Identifier expected.": { "code": 1003, "category": DiagnosticCategory.Error },
"'{0}' keyword expected.": { "code": 1004, "category": DiagnosticCategory.Error },
"'{0}' expected.": { "code": 1005, "category": DiagnosticCategory.Error },
"Identifier expected; '{0}' is a keyword.": { "code": 1006, "category": DiagnosticCategory.Error },
"Automatic semicolon insertion not allowed.": { "code": 1007, "category": DiagnosticCategory.Error },
"Unexpected token; '{0}' expected.": { "code": 1008, "category": DiagnosticCategory.Error },
"Trailing comma not allowed.": { "code": 1009, "category": DiagnosticCategory.Error },
"'*/' expected.": { "code": 1010, "category": DiagnosticCategory.Error },
"'public' or 'private' modifier must precede 'static'.": { "code": 1011, "category": DiagnosticCategory.Error },
"Unexpected token.": { "code": 1012, "category": DiagnosticCategory.Error },
"Catch clause parameter cannot have a type annotation.": { "code": 1013, "category": DiagnosticCategory.Error },
"A rest parameter must be last in a parameter list.": { "code": 1014, "category": DiagnosticCategory.Error },
"Parameter cannot have question mark and initializer.": { "code": 1015, "category": DiagnosticCategory.Error },
"A required parameter cannot follow an optional parameter.": { "code": 1016, "category": DiagnosticCategory.Error },
"Index signatures cannot have rest parameters.": { "code": 1017, "category": DiagnosticCategory.Error },
"Index signature parameter cannot have modifiers.": { "code": 1018, "category": DiagnosticCategory.Error },
"Index signature parameter cannot have a question mark.": { "code": 1019, "category": DiagnosticCategory.Error },
"Index signature parameter cannot have an initializer.": { "code": 1020, "category": DiagnosticCategory.Error },
"Index signature must have a type annotation.": { "code": 1021, "category": DiagnosticCategory.Error },
"Index signature parameter must have a type annotation.": { "code": 1022, "category": DiagnosticCategory.Error },
"Index signature parameter type must be 'string' or 'number'.": { "code": 1023, "category": DiagnosticCategory.Error },
"'extends' clause already seen.": { "code": 1024, "category": DiagnosticCategory.Error },
"'extends' clause must precede 'implements' clause.": { "code": 1025, "category": DiagnosticCategory.Error },
"Classes can only extend a single class.": { "code": 1026, "category": DiagnosticCategory.Error },
"'implements' clause already seen.": { "code": 1027, "category": DiagnosticCategory.Error },
"Accessibility modifier already seen.": { "code": 1028, "category": DiagnosticCategory.Error },
"'{0}' modifier must precede '{1}' modifier.": { "code": 1029, "category": DiagnosticCategory.Error },
"'{0}' modifier already seen.": { "code": 1030, "category": DiagnosticCategory.Error },
"'{0}' modifier cannot appear on a class element.": { "code": 1031, "category": DiagnosticCategory.Error },
"Interface declaration cannot have 'implements' clause.": { "code": 1032, "category": DiagnosticCategory.Error },
"'super' invocation cannot have type arguments.": { "code": 1034, "category": DiagnosticCategory.Error },
"Only ambient modules can use quoted names.": { "code": 1035, "category": DiagnosticCategory.Error },
"Statements are not allowed in ambient contexts.": { "code": 1036, "category": DiagnosticCategory.Error },
"A function implementation cannot be declared in an ambient context.": { "code": 1037, "category": DiagnosticCategory.Error },
"A 'declare' modifier cannot be used in an already ambient context.": { "code": 1038, "category": DiagnosticCategory.Error },
"Initializers are not allowed in ambient contexts.": { "code": 1039, "category": DiagnosticCategory.Error },
"'{0}' modifier cannot appear on a module element.": { "code": 1044, "category": DiagnosticCategory.Error },
"A 'declare' modifier cannot be used with an interface declaration.": { "code": 1045, "category": DiagnosticCategory.Error },
"A 'declare' modifier is required for a top level declaration in a .d.ts file.": { "code": 1046, "category": DiagnosticCategory.Error },
"A rest parameter cannot be optional.": { "code": 1047, "category": DiagnosticCategory.Error },
"A rest parameter cannot have an initializer.": { "code": 1048, "category": DiagnosticCategory.Error },
"'set' accessor must have exactly one parameter.": { "code": 1049, "category": DiagnosticCategory.Error },
"'set' accessor parameter cannot be optional.": { "code": 1051, "category": DiagnosticCategory.Error },
"'set' accessor parameter cannot have an initializer.": { "code": 1052, "category": DiagnosticCategory.Error },
"'set' accessor cannot have rest parameter.": { "code": 1053, "category": DiagnosticCategory.Error },
"'get' accessor cannot have parameters.": { "code": 1054, "category": DiagnosticCategory.Error },
"Modifiers cannot appear here.": { "code": 1055, "category": DiagnosticCategory.Error },
"Accessors are only available when targeting ECMAScript 5 and higher.": { "code": 1056, "category": DiagnosticCategory.Error },
"Enum member must have initializer.": { "code": 1061, "category": DiagnosticCategory.Error },
"Export assignment cannot be used in internal modules.": { "code": 1063, "category": DiagnosticCategory.Error },
"Ambient enum elements can only have integer literal initializers.": { "code": 1066, "category": DiagnosticCategory.Error },
"module, class, interface, enum, import or statement": { "code": 1067, "category": DiagnosticCategory.NoPrefix },
"constructor, function, accessor or variable": { "code": 1068, "category": DiagnosticCategory.NoPrefix },
"statement": { "code": 1069, "category": DiagnosticCategory.NoPrefix },
"case or default clause": { "code": 1070, "category": DiagnosticCategory.NoPrefix },
"identifier": { "code": 1071, "category": DiagnosticCategory.NoPrefix },
"call, construct, index, property or function signature": { "code": 1072, "category": DiagnosticCategory.NoPrefix },
"expression": { "code": 1073, "category": DiagnosticCategory.NoPrefix },
"type name": { "code": 1074, "category": DiagnosticCategory.NoPrefix },
"property or accessor": { "code": 1075, "category": DiagnosticCategory.NoPrefix },
"parameter": { "code": 1076, "category": DiagnosticCategory.NoPrefix },
"type": { "code": 1077, "category": DiagnosticCategory.NoPrefix },
"type parameter": { "code": 1078, "category": DiagnosticCategory.NoPrefix },
"A 'declare' modifier cannot be used with an import declaration.": { "code": 1079, "category": DiagnosticCategory.Error },
"Invalid 'reference' directive syntax.": { "code": 1084, "category": DiagnosticCategory.Error },
"Octal literals are not available when targeting ECMAScript 5 and higher.": { "code": 1085, "category": DiagnosticCategory.Error },
"Accessors are not allowed in ambient contexts.": { "code": 1086, "category": DiagnosticCategory.Error },
"'{0}' modifier cannot appear on a constructor declaration.": { "code": 1089, "category": DiagnosticCategory.Error },
"'{0}' modifier cannot appear on a parameter.": { "code": 1090, "category": DiagnosticCategory.Error },
"Only a single variable declaration is allowed in a 'for...in' statement.": { "code": 1091, "category": DiagnosticCategory.Error },
"Type parameters cannot appear on a constructor declaration.": { "code": 1092, "category": DiagnosticCategory.Error },
"Type annotation cannot appear on a constructor declaration.": { "code": 1093, "category": DiagnosticCategory.Error },
"Type parameters cannot appear on an accessor.": { "code": 1094, "category": DiagnosticCategory.Error },
"Type annotation cannot appear on a 'set' accessor.": { "code": 1095, "category": DiagnosticCategory.Error },
"Index signature must have exactly one parameter.": { "code": 1096, "category": DiagnosticCategory.Error },
"'{0}' list cannot be empty.": { "code": 1097, "category": DiagnosticCategory.Error },
"variable declaration": { "code": 1098, "category": DiagnosticCategory.NoPrefix },
"type argument": { "code": 1099, "category": DiagnosticCategory.NoPrefix },
"Invalid use of '{0}' in strict mode.": { "code": 1100, "category": DiagnosticCategory.Error },
"'with' statements are not allowed in strict mode.": { "code": 1101, "category": DiagnosticCategory.Error },
"'delete' cannot be called on an identifier in strict mode.": { "code": 1102, "category": DiagnosticCategory.Error },
"Invalid left-hand side in 'for...in' statement.": { "code": 1103, "category": DiagnosticCategory.Error },
"'continue' statement can only be used within an enclosing iteration statement.": { "code": 1104, "category": DiagnosticCategory.Error },
"'break' statement can only be used within an enclosing iteration or switch statement.": { "code": 1105, "category": DiagnosticCategory.Error },
"Jump target not found.": { "code": 1106, "category": DiagnosticCategory.Error },
"Jump target cannot cross function boundary.": { "code": 1107, "category": DiagnosticCategory.Error },
"'return' statement must be contained within a function body.": { "code": 1108, "category": DiagnosticCategory.Error },
"Expression expected.": { "code": 1109, "category": DiagnosticCategory.Error },
"Type expected.": { "code": 1110, "category": DiagnosticCategory.Error },
"Template literal cannot be used as an element name.": { "code": 1111, "category": DiagnosticCategory.Error },
"Computed property names cannot be used here.": { "code": 1112, "category": DiagnosticCategory.Error },
"'yield' expression must be contained within a generator declaration.": { "code": 1113, "category": DiagnosticCategory.Error },
"Unterminated regular expression literal.": { "code": 1114, "category": DiagnosticCategory.Error },
"Unterminated template literal.": { "code": 1115, "category": DiagnosticCategory.Error },
"'await' expression must be contained within an 'async' declaration.": { "code": 1116, "category": DiagnosticCategory.Error },
"'async' arrow function parameters must be parenthesized.": { "code": 1117, "category": DiagnosticCategory.Error },
"A generator declaration cannot have the 'async' modifier.": { "code": 1118, "category": DiagnosticCategory.Error },
"'async' modifier cannot appear here.": { "code": 1119, "category": DiagnosticCategory.Error },
"'comma' expression cannot appear in a computed property name.": { "code": 1120, "category": DiagnosticCategory.Error },
"String literal expected.": { "code": 1121, "category": DiagnosticCategory.Error },
"Duplicate identifier '{0}'.": { "code": 2000, "category": DiagnosticCategory.Error },
"The name '{0}' does not exist in the current scope.": { "code": 2001, "category": DiagnosticCategory.Error },
"The name '{0}' does not refer to a value.": { "code": 2002, "category": DiagnosticCategory.Error },
"'super' can only be used inside a class instance method.": { "code": 2003, "category": DiagnosticCategory.Error },
"The left-hand side of an assignment expression must be a variable, property or indexer.": { "code": 2004, "category": DiagnosticCategory.Error },
"Value of type '{0}' is not callable. Did you mean to include 'new'?": { "code": 2161, "category": DiagnosticCategory.Error },
"Value of type '{0}' is not callable.": { "code": 2006, "category": DiagnosticCategory.Error },
"Value of type '{0}' is not newable.": { "code": 2007, "category": DiagnosticCategory.Error },
"An index expression argument must be 'string', 'number', or 'any'.": { "code": 2008, "category": DiagnosticCategory.Error },
"Operator '{0}' cannot be applied to types '{1}' and '{2}'.": { "code": 2009, "category": DiagnosticCategory.Error },
"Type '{0}' is not assignable to type '{1}'.": { "code": 2011, "category": DiagnosticCategory.Error },
"Type '{0}' is not assignable to type '{1}':{NL}{2}": { "code": 2012, "category": DiagnosticCategory.Error },
"Expected var, class, interface, or module.": { "code": 2013, "category": DiagnosticCategory.Error },
"Getter '{0}' already declared.": { "code": 2015, "category": DiagnosticCategory.Error },
"Setter '{0}' already declared.": { "code": 2016, "category": DiagnosticCategory.Error },
"Exported class '{0}' extends private class '{1}'.": { "code": 2018, "category": DiagnosticCategory.Error },
"Exported class '{0}' implements private interface '{1}'.": { "code": 2019, "category": DiagnosticCategory.Error },
"Exported interface '{0}' extends private interface '{1}'.": { "code": 2020, "category": DiagnosticCategory.Error },
"Exported class '{0}' extends class from inaccessible module {1}.": { "code": 2021, "category": DiagnosticCategory.Error },
"Exported class '{0}' implements interface from inaccessible module {1}.": { "code": 2022, "category": DiagnosticCategory.Error },
"Exported interface '{0}' extends interface from inaccessible module {1}.": { "code": 2023, "category": DiagnosticCategory.Error },
"Public static property '{0}' of exported class has or is using private type '{1}'.": { "code": 2024, "category": DiagnosticCategory.Error },
"Public property '{0}' of exported class has or is using private type '{1}'.": { "code": 2025, "category": DiagnosticCategory.Error },
"Property '{0}' of exported interface has or is using private type '{1}'.": { "code": 2026, "category": DiagnosticCategory.Error },
"Exported variable '{0}' has or is using private type '{1}'.": { "code": 2027, "category": DiagnosticCategory.Error },
"Public static property '{0}' of exported class is using inaccessible module {1}.": { "code": 2028, "category": DiagnosticCategory.Error },
"Public property '{0}' of exported class is using inaccessible module {1}.": { "code": 2029, "category": DiagnosticCategory.Error },
"Property '{0}' of exported interface is using inaccessible module {1}.": { "code": 2030, "category": DiagnosticCategory.Error },
"Exported variable '{0}' is using inaccessible module {1}.": { "code": 2031, "category": DiagnosticCategory.Error },
"Parameter '{0}' of constructor from exported class has or is using private type '{1}'.": { "code": 2032, "category": DiagnosticCategory.Error },
"Parameter '{0}' of public static property setter from exported class has or is using private type '{1}'.": { "code": 2033, "category": DiagnosticCategory.Error },
"Parameter '{0}' of public property setter from exported class has or is using private type '{1}'.": { "code": 2034, "category": DiagnosticCategory.Error },
"Parameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.": { "code": 2035, "category": DiagnosticCategory.Error },
"Parameter '{0}' of call signature from exported interface has or is using private type '{1}'.": { "code": 2036, "category": DiagnosticCategory.Error },
"Parameter '{0}' of public static method from exported class has or is using private type '{1}'.": { "code": 2037, "category": DiagnosticCategory.Error },
"Parameter '{0}' of public method from exported class has or is using private type '{1}'.": { "code": 2038, "category": DiagnosticCategory.Error },
"Parameter '{0}' of method from exported interface has or is using private type '{1}'.": { "code": 2039, "category": DiagnosticCategory.Error },
"Parameter '{0}' of exported function has or is using private type '{1}'.": { "code": 2040, "category": DiagnosticCategory.Error },
"Parameter '{0}' of constructor from exported class is using inaccessible module {1}.": { "code": 2041, "category": DiagnosticCategory.Error },
"Parameter '{0}' of public static property setter from exported class is using inaccessible module {1}.": { "code": 2042, "category": DiagnosticCategory.Error },
"Parameter '{0}' of public property setter from exported class is using inaccessible module {1}.": { "code": 2043, "category": DiagnosticCategory.Error },
"Parameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.": { "code": 2044, "category": DiagnosticCategory.Error },
"Parameter '{0}' of call signature from exported interface is using inaccessible module {1}": { "code": 2045, "category": DiagnosticCategory.Error },
"Parameter '{0}' of public static method from exported class is using inaccessible module {1}.": { "code": 2046, "category": DiagnosticCategory.Error },
"Parameter '{0}' of public method from exported class is using inaccessible module {1}.": { "code": 2047, "category": DiagnosticCategory.Error },
"Parameter '{0}' of method from exported interface is using inaccessible module {1}.": { "code": 2048, "category": DiagnosticCategory.Error },
"Parameter '{0}' of exported function is using inaccessible module {1}.": { "code": 2049, "category": DiagnosticCategory.Error },
"Return type of public static property getter from exported class has or is using private type '{0}'.": { "code": 2050, "category": DiagnosticCategory.Error },
"Return type of public property getter from exported class has or is using private type '{0}'.": { "code": 2051, "category": DiagnosticCategory.Error },
"Return type of constructor signature from exported interface has or is using private type '{0}'.": { "code": 2052, "category": DiagnosticCategory.Error },
"Return type of call signature from exported interface has or is using private type '{0}'.": { "code": 2053, "category": DiagnosticCategory.Error },
"Return type of index signature from exported interface has or is using private type '{0}'.": { "code": 2054, "category": DiagnosticCategory.Error },
"Return type of public static method from exported class has or is using private type '{0}'.": { "code": 2055, "category": DiagnosticCategory.Error },
"Return type of public method from exported class has or is using private type '{0}'.": { "code": 2056, "category": DiagnosticCategory.Error },
"Return type of method from exported interface has or is using private type '{0}'.": { "code": 2057, "category": DiagnosticCategory.Error },
"Return type of exported function has or is using private type '{0}'.": { "code": 2058, "category": DiagnosticCategory.Error },
"Return type of public static property getter from exported class is using inaccessible module {0}.": { "code": 2059, "category": DiagnosticCategory.Error },
"Return type of public property getter from exported class is using inaccessible module {0}.": { "code": 2060, "category": DiagnosticCategory.Error },
"Return type of constructor signature from exported interface is using inaccessible module {0}.": { "code": 2061, "category": DiagnosticCategory.Error },
"Return type of call signature from exported interface is using inaccessible module {0}.": { "code": 2062, "category": DiagnosticCategory.Error },
"Return type of index signature from exported interface is using inaccessible module {0}.": { "code": 2063, "category": DiagnosticCategory.Error },
"Return type of public static method from exported class is using inaccessible module {0}.": { "code": 2064, "category": DiagnosticCategory.Error },
"Return type of public method from exported class is using inaccessible module {0}.": { "code": 2065, "category": DiagnosticCategory.Error },
"Return type of method from exported interface is using inaccessible module {0}.": { "code": 2066, "category": DiagnosticCategory.Error },
"Return type of exported function is using inaccessible module {0}.": { "code": 2067, "category": DiagnosticCategory.Error },
"'new T[]' cannot be used to create an array. Use 'new Array<T>()' instead.": { "code": 2068, "category": DiagnosticCategory.Error },
"A parameter list must follow a generic type argument list. '(' expected.": { "code": 2069, "category": DiagnosticCategory.Error },
"Multiple constructor implementations are not allowed.": { "code": 2070, "category": DiagnosticCategory.Error },
"Cannot find external module '{0}'.": { "code": 2071, "category": DiagnosticCategory.Error },
"Module cannot be aliased to a non-module type.": { "code": 2072, "category": DiagnosticCategory.Error },
"A class may only extend another class.": { "code": 2073, "category": DiagnosticCategory.Error },
"A class may only implement another class or interface.": { "code": 2074, "category": DiagnosticCategory.Error },
"An interface may only extend a class or another interface.": { "code": 2075, "category": DiagnosticCategory.Error },
"Unable to resolve type.": { "code": 2077, "category": DiagnosticCategory.Error },
"Unable to resolve type of '{0}'.": { "code": 2078, "category": DiagnosticCategory.Error },
"Unable to resolve type parameter constraint.": { "code": 2079, "category": DiagnosticCategory.Error },
"Type parameter constraint cannot be a primitive type.": { "code": 2080, "category": DiagnosticCategory.Error },
"Supplied parameters do not match any signature of call target.": { "code": 2081, "category": DiagnosticCategory.Error },
"Supplied parameters do not match any signature of call target:{NL}{0}": { "code": 2082, "category": DiagnosticCategory.Error },
"Cannot use 'new' with an expression whose type lacks a signature.": { "code": 2083, "category": DiagnosticCategory.Error },
"Only a void function can be called with the 'new' keyword.": { "code": 2084, "category": DiagnosticCategory.Error },
"Could not select overload for 'new' expression.": { "code": 2085, "category": DiagnosticCategory.Error },
"Type '{0}' does not satisfy the constraint '{1}'.": { "code": 2086, "category": DiagnosticCategory.Error },
"Could not select overload for 'call' expression.": { "code": 2087, "category": DiagnosticCategory.Error },
"Cannot invoke an expression whose type lacks a call signature.": { "code": 2088, "category": DiagnosticCategory.Error },
"Calls to 'super' are only valid inside a class.": { "code": 2089, "category": DiagnosticCategory.Error },
"Generic type '{0}' requires {1} type argument(s).": { "code": 2090, "category": DiagnosticCategory.Error },
"Type of array literal cannot be determined. Best common type could not be found for array elements.": { "code": 2092, "category": DiagnosticCategory.Error },
"Could not find enclosing symbol for dotted name '{0}'.": { "code": 2093, "category": DiagnosticCategory.Error },
"Property '{0}' does not exist on value of type '{1}'.": { "code": 2094, "category": DiagnosticCategory.Error },
"Cannot find name '{0}'.": { "code": 2095, "category": DiagnosticCategory.Error },
"'get' and 'set' accessor must have the same type.": { "code": 2096, "category": DiagnosticCategory.Error },
"'this' cannot be referenced in current location.": { "code": 2097, "category": DiagnosticCategory.Error },
"Static members cannot reference class type parameters.": { "code": 2099, "category": DiagnosticCategory.Error },
"Type '{0}' recursively references itself as a base type.": { "code": 2100, "category": DiagnosticCategory.Error },
"'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.": { "code": 2102, "category": DiagnosticCategory.Error },
"'super' can only be referenced in a derived class.": { "code": 2103, "category": DiagnosticCategory.Error },
"A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties.": { "code": 2104, "category": DiagnosticCategory.Error },
"Constructors for derived classes must contain a 'super' call.": { "code": 2105, "category": DiagnosticCategory.Error },
"Super calls are not permitted outside constructors or in nested functions inside constructors.": { "code": 2106, "category": DiagnosticCategory.Error },
"'{0}.{1}' is inaccessible.": { "code": 2107, "category": DiagnosticCategory.Error },
"'this' cannot be referenced in a module body.": { "code": 2108, "category": DiagnosticCategory.Error },
"Invalid '+' expression - types not known to support the addition operator.": { "code": 2111, "category": DiagnosticCategory.Error },
"The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.": { "code": 2112, "category": DiagnosticCategory.Error },
"The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.": { "code": 2113, "category": DiagnosticCategory.Error },
"An arithmetic operand must be of type 'any', 'number' or an enum type.": { "code": 2114, "category": DiagnosticCategory.Error },
"Variable declarations of a 'for' statement cannot use a type annotation.": { "code": 2115, "category": DiagnosticCategory.Error },
"Variable declarations of a 'for' statement must be of types 'string' or 'any'.": { "code": 2116, "category": DiagnosticCategory.Error },
"The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter.": { "code": 2117, "category": DiagnosticCategory.Error },
"The left-hand side of an 'in' expression must be of types 'any', 'string' or 'number'.": { "code": 2118, "category": DiagnosticCategory.Error },
"The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter.": { "code": 2119, "category": DiagnosticCategory.Error },
"The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.": { "code": 2120, "category": DiagnosticCategory.Error },
"The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type.": { "code": 2121, "category": DiagnosticCategory.Error },
"Setters cannot return a value.": { "code": 2122, "category": DiagnosticCategory.Error },
"Tried to query type of uninitialized module '{0}'.": { "code": 2123, "category": DiagnosticCategory.Error },
"Tried to set variable type to uninitialized module type '{0}'.": { "code": 2124, "category": DiagnosticCategory.Error },
"Type '{0}' is not generic.": { "code": 2125, "category": DiagnosticCategory.Error },
"Getters must return a value.": { "code": 2126, "category": DiagnosticCategory.Error },
"Getter and setter accessors do not agree in visibility.": { "code": 2127, "category": DiagnosticCategory.Error },
"Invalid left-hand side of assignment expression.": { "code": 2130, "category": DiagnosticCategory.Error },
"Function declared a non-void return type, but has no return expression.": { "code": 2131, "category": DiagnosticCategory.Error },
"Cannot resolve return type reference.": { "code": 2132, "category": DiagnosticCategory.Error },
"Constructors cannot have a return type of 'void'.": { "code": 2133, "category": DiagnosticCategory.Error },
"Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'.": { "code": 2134, "category": DiagnosticCategory.Error },
"All symbols within a with block will be resolved to 'any'.": { "code": 2135, "category": DiagnosticCategory.Error },
"Import declarations in an internal module cannot reference an external module.": { "code": 2136, "category": DiagnosticCategory.Error },
"Class {0} declares interface {1} but does not implement it:{NL}{2}": { "code": 2137, "category": DiagnosticCategory.Error },
"Class {0} declares class {1} as an interface but does not implement it:{NL}{2}": { "code": 2138, "category": DiagnosticCategory.Error },
"The operand of an increment or decrement operator must be a variable, property or indexer.": { "code": 2139, "category": DiagnosticCategory.Error },
"'this' cannot be referenced in a static property initializer.": { "code": 2140, "category": DiagnosticCategory.Error },
"Class '{0}' cannot extend class '{1}':{NL}{2}": { "code": 2141, "category": DiagnosticCategory.Error },
"Interface '{0}' cannot extend class '{1}':{NL}{2}": { "code": 2142, "category": DiagnosticCategory.Error },
"Interface '{0}' cannot extend interface '{1}':{NL}{2}": { "code": 2143, "category": DiagnosticCategory.Error },
"Overload signature is not compatible with function definition.": { "code": 2148, "category": DiagnosticCategory.Error },
"Overload signature is not compatible with function definition:{NL}{0}": { "code": 2149, "category": DiagnosticCategory.Error },
"Overload signatures must all be public or private.": { "code": 2150, "category": DiagnosticCategory.Error },
"Overload signatures must all be exported or not exported.": { "code": 2151, "category": DiagnosticCategory.Error },
"Overload signatures must all be ambient or non-ambient.": { "code": 2152, "category": DiagnosticCategory.Error },
"Overload signatures must all be optional or required.": { "code": 2153, "category": DiagnosticCategory.Error },
"Specialized overload signature is not assignable to any non-specialized signature.": { "code": 2154, "category": DiagnosticCategory.Error },
"'this' cannot be referenced in constructor arguments.": { "code": 2155, "category": DiagnosticCategory.Error },
"Instance member cannot be accessed off a class.": { "code": 2157, "category": DiagnosticCategory.Error },
"Untyped function calls may not accept type arguments.": { "code": 2158, "category": DiagnosticCategory.Error },
"Non-generic functions may not accept type arguments.": { "code": 2159, "category": DiagnosticCategory.Error },
"A generic type may not reference itself with a wrapped form of its own type parameters.": { "code": 2160, "category": DiagnosticCategory.Error },
"A rest parameter must be of an array type.": { "code": 2162, "category": DiagnosticCategory.Error },
"Overload signature implementation cannot use specialized type.": { "code": 2163, "category": DiagnosticCategory.Error },
"Export assignments may only be used at the top-level of external modules.": { "code": 2164, "category": DiagnosticCategory.Error },
"Export assignments may only be made with variables, functions, classes, interfaces, enums and internal modules.": { "code": 2165, "category": DiagnosticCategory.Error },
"Only public methods of the base class are accessible via the 'super' keyword.": { "code": 2166, "category": DiagnosticCategory.Error },
"Numeric indexer type '{0}' must be assignable to string indexer type '{1}'.": { "code": 2167, "category": DiagnosticCategory.Error },
"Numeric indexer type '{0}' must be assignable to string indexer type '{1}':{NL}{2}": { "code": 2168, "category": DiagnosticCategory.Error },
"All numerically named properties must be assignable to numeric indexer type '{0}'.": { "code": 2169, "category": DiagnosticCategory.Error },
"All numerically named properties must be assignable to numeric indexer type '{0}':{NL}{1}": { "code": 2170, "category": DiagnosticCategory.Error },
"All named properties must be assignable to string indexer type '{0}'.": { "code": 2171, "category": DiagnosticCategory.Error },
"All named properties must be assignable to string indexer type '{0}':{NL}{1}": { "code": 2172, "category": DiagnosticCategory.Error },
"A parameter initializer is only allowed in a function or constructor implementation.": { "code": 2174, "category": DiagnosticCategory.Error },
"Function expression declared a non-void return type, but has no return expression.": { "code": 2176, "category": DiagnosticCategory.Error },
"Import declaration referencing identifier from internal module can only be made with variables, functions, classes, interfaces, enums and internal modules.": { "code": 2177, "category": DiagnosticCategory.Error },
"Module '{0}' has no exported member '{1}'.": { "code": 2178, "category": DiagnosticCategory.Error },
"Unable to resolve module reference '{0}'.": { "code": 2179, "category": DiagnosticCategory.Error },
"Could not find module '{0}' in module '{1}'.": { "code": 2180, "category": DiagnosticCategory.Error },
"Exported import declaration '{0}' is assigned value with type that has or is using private type '{1}'.": { "code": 2181, "category": DiagnosticCategory.Error },
"Exported import declaration '{0}' is assigned value with type that is using inaccessible module '{1}'.": { "code": 2182, "category": DiagnosticCategory.Error },
"Exported import declaration '{0}' is assigned type that has or is using private type '{1}'.": { "code": 2183, "category": DiagnosticCategory.Error },
"Exported import declaration '{0}' is assigned type that is using inaccessible module '{1}'.": { "code": 2184, "category": DiagnosticCategory.Error },
"Exported import declaration '{0}' is assigned container that is or is using inaccessible module '{1}'.": { "code": 2185, "category": DiagnosticCategory.Error },
"Type name '{0}' in extends clause does not reference constructor function for '{1}'.": { "code": 2186, "category": DiagnosticCategory.Error },
"Internal module reference '{0}' in import declaration does not reference module instance for '{1}'.": { "code": 2187, "category": DiagnosticCategory.Error },
"Module '{0}' cannot merge with previous declaration of '{1}' in a different file '{2}'.": { "code": 2188, "category": DiagnosticCategory.Error },
"Interface '{0}' cannot simultaneously extend types '{1}' and '{2}':{NL}{3}": { "code": 2189, "category": DiagnosticCategory.Error },
"Initializer of parameter '{0}' cannot reference identifier '{1}' declared after it.": { "code": 2190, "category": DiagnosticCategory.Error },
"Ambient external module declaration cannot be reopened.": { "code": 2191, "category": DiagnosticCategory.Error },
"All declarations of merged declaration '{0}' must be exported or not exported.": { "code": 2192, "category": DiagnosticCategory.Error },
"'super' cannot be referenced in constructor arguments.": { "code": 2193, "category": DiagnosticCategory.Error },
"Return type of constructor signature must be assignable to the instance type of the class.": { "code": 2194, "category": DiagnosticCategory.Error },
"Ambient external module declaration must be defined in global context.": { "code": 2195, "category": DiagnosticCategory.Error },
"Ambient external module declaration cannot specify relative module name.": { "code": 2196, "category": DiagnosticCategory.Error },
"Import declaration in an ambient external module declaration cannot reference external module through relative external module name.": { "code": 2197, "category": DiagnosticCategory.Error },
"No best common type exists among return expressions.": { "code": 2198, "category": DiagnosticCategory.Error },
"Import declaration cannot refer to external module reference when --noResolve option is set.": { "code": 2199, "category": DiagnosticCategory.Error },
"Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference.": { "code": 2200, "category": DiagnosticCategory.Error },
"Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference.": { "code": 2205, "category": DiagnosticCategory.Error },
"Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference.": { "code": 2206, "category": DiagnosticCategory.Error },
"Expression resolves to '_super' that compiler uses to capture base class reference.": { "code": 2207, "category": DiagnosticCategory.Error },
"TypeParameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.": { "code": 2208, "category": DiagnosticCategory.Error },
"TypeParameter '{0}' of call signature from exported interface has or is using private type '{1}'.": { "code": 2209, "category": DiagnosticCategory.Error },
"TypeParameter '{0}' of public static method from exported class has or is using private type '{1}'.": { "code": 2210, "category": DiagnosticCategory.Error },
"TypeParameter '{0}' of public method from exported class has or is using private type '{1}'.": { "code": 2211, "category": DiagnosticCategory.Error },
"TypeParameter '{0}' of method from exported interface has or is using private type '{1}'.": { "code": 2212, "category": DiagnosticCategory.Error },
"TypeParameter '{0}' of exported function has or is using private type '{1}'.": { "code": 2213, "category": DiagnosticCategory.Error },
"TypeParameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.": { "code": 2214, "category": DiagnosticCategory.Error },
"TypeParameter '{0}' of call signature from exported interface is using inaccessible module {1}": { "code": 2215, "category": DiagnosticCategory.Error },
"TypeParameter '{0}' of public static method from exported class is using inaccessible module {1}.": { "code": 2216, "category": DiagnosticCategory.Error },
"TypeParameter '{0}' of public method from exported class is using inaccessible module {1}.": { "code": 2217, "category": DiagnosticCategory.Error },
"TypeParameter '{0}' of method from exported interface is using inaccessible module {1}.": { "code": 2218, "category": DiagnosticCategory.Error },
"TypeParameter '{0}' of exported function is using inaccessible module {1}.": { "code": 2219, "category": DiagnosticCategory.Error },
"TypeParameter '{0}' of exported class has or is using private type '{1}'.": { "code": 2220, "category": DiagnosticCategory.Error },
"TypeParameter '{0}' of exported interface has or is using private type '{1}'.": { "code": 2221, "category": DiagnosticCategory.Error },
"TypeParameter '{0}' of exported class is using inaccessible module {1}.": { "code": 2222, "category": DiagnosticCategory.Error },
"TypeParameter '{0}' of exported interface is using inaccessible module {1}.": { "code": 2223, "category": DiagnosticCategory.Error },
"Duplicate identifier '_i'. Compiler uses '_i' to initialize rest parameter.": { "code": 2224, "category": DiagnosticCategory.Error },
"Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters.": { "code": 2225, "category": DiagnosticCategory.Error },
"No best common type exists between '{0}' and '{1}'.": { "code": 2226, "category": DiagnosticCategory.Error },
"No best common type exists between '{0}', '{1}', and '{2}'.": { "code": 2227, "category": DiagnosticCategory.Error },
"Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of an external module.": { "code": 2228, "category": DiagnosticCategory.Error },
"Constraint of a type parameter cannot reference any type parameter from the same type parameter list.": { "code": 2229, "category": DiagnosticCategory.Error },
"Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor.": { "code": 2230, "category": DiagnosticCategory.Error },
"Parameter '{0}' cannot be referenced in its initializer.": { "code": 2231, "category": DiagnosticCategory.Error },
"Duplicate string index signature.": { "code": 2232, "category": DiagnosticCategory.Error },
"Duplicate number index signature.": { "code": 2233, "category": DiagnosticCategory.Error },
"All declarations of an interface must have identical type parameters.": { "code": 2234, "category": DiagnosticCategory.Error },
"Expression resolves to variable declaration '_i' that compiler uses to initialize rest parameter.": { "code": 2235, "category": DiagnosticCategory.Error },
"Neither type '{0}' nor type '{1}' is assignable to the other.": { "code": 2236, "category": DiagnosticCategory.Error },
"Neither type '{0}' nor type '{1}' is assignable to the other:{NL}{2}": { "code": 2237, "category": DiagnosticCategory.Error },
"Duplicate function implementation.": { "code": 2237, "category": DiagnosticCategory.Error },
"Function implementation expected.": { "code": 2238, "category": DiagnosticCategory.Error },
"Function overload name must be '{0}'.": { "code": 2239, "category": DiagnosticCategory.Error },
"Constructor implementation expected.": { "code": 2240, "category": DiagnosticCategory.Error },
"Class name cannot be '{0}'.": { "code": 2241, "category": DiagnosticCategory.Error },
"Interface name cannot be '{0}'.": { "code": 2242, "category": DiagnosticCategory.Error },
"Enum name cannot be '{0}'.": { "code": 2243, "category": DiagnosticCategory.Error },
"A module cannot have multiple export assignments.": { "code": 2244, "category": DiagnosticCategory.Error },
"Export assignment not allowed in module with exported element.": { "code": 2245, "category": DiagnosticCategory.Error },
"A parameter property is only allowed in a constructor implementation.": { "code": 2246, "category": DiagnosticCategory.Error },
"Function overload must be static.": { "code": 2247, "category": DiagnosticCategory.Error },
"Function overload must not be static.": { "code": 2248, "category": DiagnosticCategory.Error },
"Type '{0}' is missing property '{1}' from type '{2}'.": { "code": 4000, "category": DiagnosticCategory.NoPrefix },
"Types of property '{0}' of types '{1}' and '{2}' are incompatible.": { "code": 4001, "category": DiagnosticCategory.NoPrefix },
"Types of property '{0}' of types '{1}' and '{2}' are incompatible:{NL}{3}": { "code": 4002, "category": DiagnosticCategory.NoPrefix },
"Property '{0}' defined as private in type '{1}' is defined as public in type '{2}'.": { "code": 4003, "category": DiagnosticCategory.NoPrefix },
"Property '{0}' defined as public in type '{1}' is defined as private in type '{2}'.": { "code": 4004, "category": DiagnosticCategory.NoPrefix },
"Types '{0}' and '{1}' define property '{2}' as private.": { "code": 4005, "category": DiagnosticCategory.NoPrefix },
"Call signatures of types '{0}' and '{1}' are incompatible.": { "code": 4006, "category": DiagnosticCategory.NoPrefix },
"Call signatures of types '{0}' and '{1}' are incompatible:{NL}{2}": { "code": 4007, "category": DiagnosticCategory.NoPrefix },
"Type '{0}' requires a call signature, but type '{1}' lacks one.": { "code": 4008, "category": DiagnosticCategory.NoPrefix },
"Construct signatures of types '{0}' and '{1}' are incompatible.": { "code": 4009, "category": DiagnosticCategory.NoPrefix },
"Construct signatures of types '{0}' and '{1}' are incompatible:{NL}{2}": { "code": 4010, "category": DiagnosticCategory.NoPrefix },
"Type '{0}' requires a construct signature, but type '{1}' lacks one.": { "code": 4011, "category": DiagnosticCategory.NoPrefix },
"Index signatures of types '{0}' and '{1}' are incompatible.": { "code": 4012, "category": DiagnosticCategory.NoPrefix },
"Index signatures of types '{0}' and '{1}' are incompatible:{NL}{2}": { "code": 4013, "category": DiagnosticCategory.NoPrefix },
"Call signature expects {0} or fewer parameters.": { "code": 4014, "category": DiagnosticCategory.NoPrefix },
"Could not apply type '{0}' to argument {1} which is of type '{2}'.": { "code": 4015, "category": DiagnosticCategory.NoPrefix },
"Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function.": { "code": 4016, "category": DiagnosticCategory.NoPrefix },
"Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function.": { "code": 4017, "category": DiagnosticCategory.NoPrefix },
"Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor.": { "code": 4018, "category": DiagnosticCategory.NoPrefix },
"Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property.": { "code": 4019, "category": DiagnosticCategory.NoPrefix },
"Types of static property '{0}' of class '{1}' and class '{2}' are incompatible.": { "code": 4020, "category": DiagnosticCategory.NoPrefix },
"Types of static property '{0}' of class '{1}' and class '{2}' are incompatible:{NL}{3}": { "code": 4021, "category": DiagnosticCategory.NoPrefix },
"Type reference cannot refer to container '{0}'.": { "code": 4022, "category": DiagnosticCategory.Error },
"Type reference must refer to type.": { "code": 4023, "category": DiagnosticCategory.Error },
"In enums with multiple declarations only one declaration can omit an initializer for the first enum element.": { "code": 4024, "category": DiagnosticCategory.Error },
" (+ {0} overload(s))": { "code": 4025, "category": DiagnosticCategory.Message },
"Variable declaration cannot have the same name as an import declaration.": { "code": 4026, "category": DiagnosticCategory.Error },
"Signature expected {0} type arguments, got {1} instead.": { "code": 4027, "category": DiagnosticCategory.Error },
"Property '{0}' defined as optional in type '{1}', but is required in type '{2}'.": { "code": 4028, "category": DiagnosticCategory.NoPrefix },
"Types '{0}' and '{1}' originating in infinitely expanding type reference do not refer to same named type.": { "code": 4029, "category": DiagnosticCategory.NoPrefix },
"Types '{0}' and '{1}' originating in infinitely expanding type reference have incompatible type arguments.": { "code": 4030, "category": DiagnosticCategory.NoPrefix },
"Types '{0}' and '{1}' originating in infinitely expanding type reference have incompatible type arguments:{NL}{2}": { "code": 4031, "category": DiagnosticCategory.NoPrefix },
"Named properties '{0}' of types '{1}' and '{2}' are not identical.": { "code": 4032, "category": DiagnosticCategory.NoPrefix },
"Types of string indexer of types '{0}' and '{1}' are not identical.": { "code": 4033, "category": DiagnosticCategory.NoPrefix },
"Types of number indexer of types '{0}' and '{1}' are not identical.": { "code": 4034, "category": DiagnosticCategory.NoPrefix },
"Type of number indexer in type '{0}' is not assignable to string indexer type in type '{1}'.{NL}{2}": { "code": 4035, "category": DiagnosticCategory.NoPrefix },
"Type of property '{0}' in type '{1}' is not assignable to string indexer type in type '{2}'.{NL}{3}": { "code": 4036, "category": DiagnosticCategory.NoPrefix },
"Type of property '{0}' in type '{1}' is not assignable to number indexer type in type '{2}'.{NL}{3}": { "code": 4037, "category": DiagnosticCategory.NoPrefix },
"Static property '{0}' defined as private in type '{1}' is defined as public in type '{2}'.": { "code": 4038, "category": DiagnosticCategory.NoPrefix },
"Static property '{0}' defined as public in type '{1}' is defined as private in type '{2}'.": { "code": 4039, "category": DiagnosticCategory.NoPrefix },
"Types '{0}' and '{1}' define static property '{2}' as private.": { "code": 4040, "category": DiagnosticCategory.NoPrefix },
"Current host does not support '{0}' option.": { "code": 5001, "category": DiagnosticCategory.Error },
"ECMAScript target version '{0}' not supported. Specify a valid target version: '{1}' (default), or '{2}'": { "code": 5002, "category": DiagnosticCategory.Error },
"Argument for '{0}' option must be '{1}' or '{2}'": { "code": 5003, "category": DiagnosticCategory.Error },
"Could not find file: '{0}'.": { "code": 5004, "category": DiagnosticCategory.Error },
"A file cannot have a reference to itself.": { "code": 5006, "category": DiagnosticCategory.Error },
"Cannot resolve referenced file: '{0}'.": { "code": 5007, "category": DiagnosticCategory.Error },
"Cannot find the common subdirectory path for the input files.": { "code": 5009, "category": DiagnosticCategory.Error },
"Emit Error: {0}.": { "code": 5011, "category": DiagnosticCategory.Error },
"Cannot read file '{0}': {1}": { "code": 5012, "category": DiagnosticCategory.Error },
"Unsupported file encoding.": { "code": 5013, "category": DiagnosticCategory.NoPrefix },
"Locale must be of the form <language> or <language>-<territory>. For example '{0}' or '{1}'.": { "code": 5014, "category": DiagnosticCategory.Error },
"Unsupported locale: '{0}'.": { "code": 5015, "category": DiagnosticCategory.Error },
"Execution Failed.{NL}": { "code": 5016, "category": DiagnosticCategory.Error },
"Invalid call to 'up'": { "code": 5019, "category": DiagnosticCategory.Error },
"Invalid call to 'down'": { "code": 5020, "category": DiagnosticCategory.Error },
"Base64 value '{0}' finished with a continuation bit.": { "code": 5021, "category": DiagnosticCategory.Error },
"Unknown compiler option '{0}'": { "code": 5023, "category": DiagnosticCategory.Error },
"Expected {0} arguments to message, got {1} instead.": { "code": 5024, "category": DiagnosticCategory.Error },
"Expected the message '{0}' to have {1} arguments, but it had {2}": { "code": 5025, "category": DiagnosticCategory.Error },
"Could not delete file '{0}'": { "code": 5034, "category": DiagnosticCategory.Error },
"Could not create directory '{0}'": { "code": 5035, "category": DiagnosticCategory.Error },
"Error while executing file '{0}': ": { "code": 5036, "category": DiagnosticCategory.Error },
"Cannot compile external modules unless the '--module' flag is provided.": { "code": 5037, "category": DiagnosticCategory.Error },
"Option mapRoot cannot be specified without specifying sourcemap option.": { "code": 5038, "category": DiagnosticCategory.Error },
"Option sourceRoot cannot be specified without specifying sourcemap option.": { "code": 5039, "category": DiagnosticCategory.Error },
"Options mapRoot and sourceRoot cannot be specified without specifying sourcemap option.": { "code": 5040, "category": DiagnosticCategory.Error },
"Option '{0}' specified without '{1}'": { "code": 5041, "category": DiagnosticCategory.Error },
"'codepage' option not supported on current platform.": { "code": 5042, "category": DiagnosticCategory.Error },
"Concatenate and emit output to single file.": { "code": 6001, "category": DiagnosticCategory.Message },
"Generates corresponding {0} file.": { "code": 6002, "category": DiagnosticCategory.Message },
"Specifies the location where debugger should locate map files instead of generated locations.": { "code": 6003, "category": DiagnosticCategory.Message },
"Specifies the location where debugger should locate TypeScript files instead of source locations.": { "code": 6004, "category": DiagnosticCategory.Message },
"Watch input files.": { "code": 6005, "category": DiagnosticCategory.Message },
"Redirect output structure to the directory.": { "code": 6006, "category": DiagnosticCategory.Message },
"Do not emit comments to output.": { "code": 6009, "category": DiagnosticCategory.Message },
"Skip resolution and preprocessing.": { "code": 6010, "category": DiagnosticCategory.Message },
"Specify ECMAScript target version: '{0}' (default), or '{1}'": { "code": 6015, "category": DiagnosticCategory.Message },
"Specify module code generation: '{0}' or '{1}'": { "code": 6016, "category": DiagnosticCategory.Message },
"Print this message.": { "code": 6017, "category": DiagnosticCategory.Message },
"Print the compiler's version: {0}": { "code": 6019, "category": DiagnosticCategory.Message },
"Allow use of deprecated '{0}' keyword when referencing an external module.": { "code": 6021, "category": DiagnosticCategory.Message },
"Specify locale for errors and messages. For example '{0}' or '{1}'": { "code": 6022, "category": DiagnosticCategory.Message },
"Syntax: {0}": { "code": 6023, "category": DiagnosticCategory.Message },
"options": { "code": 6024, "category": DiagnosticCategory.Message },
"file1": { "code": 6025, "category": DiagnosticCategory.Message },
"Examples:": { "code": 6026, "category": DiagnosticCategory.Message },
"Options:": { "code": 6027, "category": DiagnosticCategory.Message },
"Insert command line options and files from a file.": { "code": 6030, "category": DiagnosticCategory.Message },
"Version {0}": { "code": 6029, "category": DiagnosticCategory.Message },
"Use the '{0}' flag to see options.": { "code": 6031, "category": DiagnosticCategory.Message },
"{NL}Recompiling ({0}):": { "code": 6032, "category": DiagnosticCategory.Message },
"STRING": { "code": 6033, "category": DiagnosticCategory.Message },
"KIND": { "code": 6034, "category": DiagnosticCategory.Message },
"file2": { "code": 6035, "category": DiagnosticCategory.Message },
"VERSION": { "code": 6036, "category": DiagnosticCategory.Message },
"LOCATION": { "code": 6037, "category": DiagnosticCategory.Message },
"DIRECTORY": { "code": 6038, "category": DiagnosticCategory.Message },
"NUMBER": { "code": 6039, "category": DiagnosticCategory.Message },
"Specify the codepage to use when opening source files.": { "code": 6040, "category": DiagnosticCategory.Message },
"Additional locations:": { "code": 6041, "category": DiagnosticCategory.Message },
"This version of the Javascript runtime does not support the '{0}' function.": { "code": 7000, "category": DiagnosticCategory.Error },
"Unknown rule.": { "code": 7002, "category": DiagnosticCategory.Error },
"Invalid line number ({0})": { "code": 7003, "category": DiagnosticCategory.Error },
"Warn on expressions and declarations with an implied 'any' type.": { "code": 7004, "category": DiagnosticCategory.Message },
"Variable '{0}' implicitly has an 'any' type.": { "code": 7005, "category": DiagnosticCategory.Error },
"Parameter '{0}' of '{1}' implicitly has an 'any' type.": { "code": 7006, "category": DiagnosticCategory.Error },
"Parameter '{0}' of function type implicitly has an 'any' type.": { "code": 7007, "category": DiagnosticCategory.Error },
"Member '{0}' of object type implicitly has an 'any' type.": { "code": 7008, "category": DiagnosticCategory.Error },
"'new' expression, which lacks a constructor signature, implicitly has an 'any' type.": { "code": 7009, "category": DiagnosticCategory.Error },
"'{0}', which lacks return-type annotation, implicitly has an 'any' return type.": { "code": 7010, "category": DiagnosticCategory.Error },
"Function expression, which lacks return-type annotation, implicitly has an 'any' return type.": { "code": 7011, "category": DiagnosticCategory.Error },
"Parameter '{0}' of lambda function implicitly has an 'any' type.": { "code": 7012, "category": DiagnosticCategory.Error },
"Constructor signature, which lacks return-type annotation, implicitly has an 'any' return type.": { "code": 7013, "category": DiagnosticCategory.Error },
"Lambda Function, which lacks return-type annotation, implicitly has an 'any' return type.": { "code": 7014, "category": DiagnosticCategory.Error },
"Array Literal implicitly has an 'any' type from widening.": { "code": 7015, "category": DiagnosticCategory.Error },
"'{0}', which lacks 'get' accessor and parameter type annotation on 'set' accessor, implicitly has an 'any' type.": { "code": 7016, "category": DiagnosticCategory.Error },
"Index signature of object type implicitly has an 'any' type.": { "code": 7017, "category": DiagnosticCategory.Error },
"Object literal's property '{0}' implicitly has an 'any' type from widening.": { "code": 7018, "category": DiagnosticCategory.Error },
};
}

File diff suppressed because it is too large Load diff

View file

@ -1,2 +0,0 @@
/// <reference path='diagnosticCode.generated.ts' />
/// <reference path='diagnosticInformationMap.generated.ts' />

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

View file

@ -1,70 +0,0 @@
///<reference path='references.ts' />
module TypeScript {
export module CharacterInfo {
export function isDecimalDigit(c: number): boolean {
return c >= CharacterCodes._0 && c <= CharacterCodes._9;
}
export function isOctalDigit(c: number): boolean {
return c >= CharacterCodes._0 && c <= CharacterCodes._7;
}
export function isHexDigit(c: number): boolean {
return CharacterInfo.isDecimalDigit(c) ||
(c >= CharacterCodes.A && c <= CharacterCodes.F) ||
(c >= CharacterCodes.a && c <= CharacterCodes.f);
}
export function hexValue(c: number): number {
// Debug.assert(isHexDigit(c));
return CharacterInfo.isDecimalDigit(c)
? (c - CharacterCodes._0)
: (c >= CharacterCodes.A && c <= CharacterCodes.F)
? c - CharacterCodes.A + 10
: c - CharacterCodes.a + 10;
}
export function isWhitespace(ch: number): boolean {
switch (ch) {
// Unicode 3.0 space characters.
case CharacterCodes.space:
case CharacterCodes.nonBreakingSpace:
case CharacterCodes.enQuad:
case CharacterCodes.emQuad:
case CharacterCodes.enSpace:
case CharacterCodes.emSpace:
case CharacterCodes.threePerEmSpace:
case CharacterCodes.fourPerEmSpace:
case CharacterCodes.sixPerEmSpace:
case CharacterCodes.figureSpace:
case CharacterCodes.punctuationSpace:
case CharacterCodes.thinSpace:
case CharacterCodes.hairSpace:
case CharacterCodes.zeroWidthSpace:
case CharacterCodes.narrowNoBreakSpace:
case CharacterCodes.ideographicSpace:
case CharacterCodes.tab:
case CharacterCodes.verticalTab:
case CharacterCodes.formFeed:
case CharacterCodes.byteOrderMark:
return true;
}
return false;
}
export function isLineTerminator(ch: number): boolean {
switch (ch) {
case CharacterCodes.carriageReturn:
case CharacterCodes.lineFeed:
case CharacterCodes.paragraphSeparator:
case CharacterCodes.lineSeparator:
return true;
}
return false;
}
}
}

View file

@ -1,26 +0,0 @@
///<reference path='references.ts' />
module TypeScript {
export const enum ParserContextFlags {
StrictMode = 1 << 0,
DisallowIn = 1 << 1,
Yield = 1 << 2,
GeneratorParameter = 1 << 3,
Async = 1 << 4,
Mask = 0x1F
}
export enum SyntaxNodeConstants {
None = 0,
// The first five bit of the flags are used to store parser context flags. The next bit
// marks if we've computed the transitive data for the node. The next bit marks if the node
// is incrementally unusable.
//
// The width of the node is stored in the remainder of the number.
DataComputed = 1 << 5, // 0000 0000 0000 0000 0000 0000 0010 0000
IncrementallyUnusableMask = 1 << 6, // 0000 0000 0000 0000 0000 0000 0100 0000
FullWidthShift = 1 << 7, // 1111 1111 1111 1111 1111 1111 1000 0000
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,13 +0,0 @@
///<reference path='references.ts' />
module TypeScript {
export class FormattingOptions {
constructor(public useTabs: boolean,
public spacesPerTab: number,
public indentSpaces: number,
public newLineCharacter: string) {
}
public static defaultOptions = new FormattingOptions(/*useTabs:*/ false, /*spacesPerTab:*/ 4, /*indentSpaces:*/ 4, /*newLineCharacter*/ "\r\n");
}
}

View file

@ -1,428 +0,0 @@
///<reference path="references.ts" />
module TypeScript.IncrementalParser {
interface ISyntaxElementInternal extends ISyntaxElement {
intersectsChange: boolean;
}
// Parser source used in incremental scenarios. This parser source wraps an old tree, text
// change and new text, and uses all three to provide nodes and tokens to the parser. In
// general, nodes from the old tree are returned as long as they do not intersect with the text
// change. Then, once the text change is reached, tokens from the old tree are returned as
// long as they do not intersect with the text change. Then, the text that is actually changed
// will be scanned using a normal scanner. Then, once the new text is scanned, the source will
// attempt to sync back up with nodes or tokens that started where the new tokens end. Once it
// can do that, then all subsequent data will come from the original tree.
//
// This allows for an enormous amount of tree reuse in common scenarios. Situations that
// prevent this level of reuse include substantially destructive operations like introducing
// "/*" without a "*/" nearby to terminate the comment.
function createParserSource(oldSyntaxTree: SyntaxTree, textChangeRange: TextChangeRange, text: ISimpleText): Parser.IParserSource {
// The underlying source that we will use to scan tokens from any new text, or any tokens
// from the old tree that we decide we can't use for any reason. We will also continue
// scanning tokens from this source until we've decided that we're resynchronized and can
// read in subsequent data from the old tree.
//
// This parser source also keeps track of the absolute position in the text that we're in,
// and any token diagnostics produced. That way we dont' have to track that ourselves.
var scannerParserSource = Scanner.createParserSource(oldSyntaxTree.fileName(), text, oldSyntaxTree.languageVersion());
// The cursor we use to navigate through and retrieve nodes and tokens from the old tree.
var oldSourceUnit = oldSyntaxTree.sourceUnit();
// Start the cursor pointing at the first element in the source unit (if it exists).
var oldSourceUnitCursor = getSyntaxCursor();
if (oldSourceUnit.moduleElements.length > 0) {
oldSourceUnitCursor.pushElement(childAt(oldSourceUnit.moduleElements, 0), /*indexInParent:*/ 0);
}
// In general supporting multiple individual edits is just not that important. So we
// just collapse this all down to a single range to make the code here easier. The only
// time this could be problematic would be if the user made a ton of discontinuous edits.
// For example, doing a column select on a *large* section of a code. If this is a
// problem, we can always update this code to handle multiple changes.
var changeRange = extendToAffectedRange(textChangeRange, oldSourceUnit);
// The old tree's length, plus whatever length change was caused by the edit
// Had better equal the new text's length!
if (Debug.shouldAssert(AssertionLevel.Aggressive)) {
Debug.assert((fullWidth(oldSourceUnit) - changeRange.span().length() + changeRange.newLength()) === text.length());
}
var delta = changeRange.newSpan().length() - changeRange.span().length();
// If we added or removed characters during the edit, then we need to go and adjust all
// the nodes after the edit. Those nodes may move forward down (if we inserted chars)
// or they may move backward (if we deleted chars).
//
// Doing this helps us out in two ways. First, it means that any nodes/tokens we want
// to reuse are already at the appropriate position in the new text. That way when we
// reuse them, we don't have to figure out if they need to be adjusted. Second, it makes
// it very easy to determine if we can reuse a node. If the node's position is at where
// we are in the text, then we can reuse it. Otherwise we can't. If hte node's position
// is ahead of us, then we'll need to rescan tokens. If the node's position is behind
// us, then we'll need to skip it or crumble it as appropriate
//
// Also, mark any syntax elements that intersect the changed span. We know, up front,
// that we cannot reuse these elements.
updateTokenPositionsAndMarkElements(<ISyntaxElementInternal><ISyntaxElement>oldSourceUnit,
changeRange.span().start(), changeRange.span().end(), delta, /*fullStart:*/ 0);
function extendToAffectedRange(changeRange: TextChangeRange, sourceUnit: SourceUnitSyntax): TextChangeRange {
// Consider the following code:
// void foo() { /; }
//
// If the text changes with an insertion of / just before the semicolon then we end up with:
// void foo() { //; }
//
// If we were to just use the changeRange a is, then we would not rescan the { token
// (as it does not intersect the actual original change range). Because an edit may
// change the token touching it, we actually need to look back *at least* one token so
// that the prior token sees that change.
var maxLookahead = 1;
var start = changeRange.span().start();
// the first iteration aligns us with the change start. subsequent iteration move us to
// the left by maxLookahead tokens. We only need to do this as long as we're not at the
// start of the tree.
for (var i = 0; start > 0 && i <= maxLookahead; i++) {
var token = findToken(sourceUnit, start);
var position = token.fullStart();
start = Math.max(0, position - 1);
}
var finalSpan = TextSpan.fromBounds(start, changeRange.span().end());
var finalLength = changeRange.newLength() + (changeRange.span().start() - start);
return new TextChangeRange(finalSpan, finalLength);
}
function absolutePosition() {
return scannerParserSource.absolutePosition();
}
function diagnostics(): Diagnostic[] {
return scannerParserSource.diagnostics();
}
function tryParse<T extends ISyntaxNode>(callback: () => T): T {
// Clone our cursor. That way we can restore to that point if the parser needs to rewind.
var savedOldSourceUnitCursor = cloneSyntaxCursor(oldSourceUnitCursor);
// Now defer to our underlying scanner source to actually invoke the callback. That
// way, if the parser decides to rewind, both the scanner source and this incremental
// source will rewind appropriately.
var result = scannerParserSource.tryParse(callback);
if (!result) {
// We're rewinding. Reset the cursor to what it was when we got the rewind point.
// Make sure to return our existing cursor to the pool so it can be reused.
returnSyntaxCursor(oldSourceUnitCursor);
oldSourceUnitCursor = savedOldSourceUnitCursor;
}
else {
// We're not rewinding. Return the cloned original cursor back to the pool.
returnSyntaxCursor(savedOldSourceUnitCursor);
}
return result;
}
function trySynchronizeCursorToPosition() {
var absolutePos = absolutePosition();
while (true) {
if (oldSourceUnitCursor.isFinished()) {
// Can't synchronize the cursor to the current position if the cursor is finished.
return false;
}
// Start with the current node or token the cursor is pointing at.
var currentNodeOrToken = oldSourceUnitCursor.currentNodeOrToken();
// Node, move the cursor past any nodes or tokens that intersect the change range
// 1) they are never reusable.
// 2) their positions are wacky as they refer to the original text.
//
// We consider these nodes and tokens essentially invisible to all further parts
// of the incremental algorithm.
if ((<ISyntaxElementInternal><ISyntaxElement>currentNodeOrToken).intersectsChange) {
if (isNode(currentNodeOrToken)) {
oldSourceUnitCursor.moveToFirstChild();
}
else {
oldSourceUnitCursor.moveToNextSibling();
}
continue;
}
var currentNodeOrTokenFullStart = fullStart(currentNodeOrToken);
if (currentNodeOrTokenFullStart === absolutePos) {
// We were able to synchronize the cursor to the current position. We can
// read from the cursor
return true;
}
if (currentNodeOrTokenFullStart > absolutePos) {
// The node or token is ahead of the current position. We'll need to rescan
// tokens until we catch up.
return false;
}
// The node or is behind the current position we're at in the text.
var currentNodeOrTokenFullWidth = fullWidth(currentNodeOrToken);
var currentNodeOrTokenFullEnd = currentNodeOrTokenFullStart + currentNodeOrTokenFullWidth;
// If we're pointing at a node, and that node ends before our current position, we
// can just skip the node entirely. Or, if we're pointing at a token, we won't be
// able to break up that token any further and we should just move to the next
// token.
if (currentNodeOrTokenFullEnd <= absolutePos || isToken(currentNodeOrToken)) {
oldSourceUnitCursor.moveToNextSibling();
}
else {
// We have a node, and it started before our absolute pos, and ended after our
// pos. Try to crumble this node to see if we'll be able to skip the first node
// or token contained within.
oldSourceUnitCursor.moveToFirstChild();
}
}
}
function currentNode(): ISyntaxNode {
if (trySynchronizeCursorToPosition()) {
// Try to read a node. If we can't then our caller will call back in and just try
// to get a token.
var node = tryGetNodeFromOldSourceUnit();
if (node) {
return node;
}
}
// Either we were ahead of the old text, or we were pinned. No node can be read here.
return undefined;
}
function currentToken(): ISyntaxToken {
if (trySynchronizeCursorToPosition()) {
var token = tryGetTokenFromOldSourceUnit();
if (token) {
return token;
}
}
// Either we couldn't read from the old source unit, or we weren't able to successfully
// get a token from it. In this case we need to read a token from the underlying text.
return scannerParserSource.currentToken();
}
function currentContextualToken(): ISyntaxToken {
// Just delegate to the underlying source to handle
return scannerParserSource.currentContextualToken();
}
function tryGetNodeFromOldSourceUnit(): ISyntaxNode {
// Keep moving the cursor down to the first node that is safe to return. A node is
// safe to return if:
// a) it does not contain skipped text.
// b) it does not have any zero width tokens in it.
// c) it does not have a regex token in it.
// d) we are still in the same strict or non-strict state that the node was originally parsed in.
while (true) {
var node = oldSourceUnitCursor.currentNode();
if (node === undefined) {
// Couldn't even read a node, nothing to return.
return undefined;
}
if (!TypeScript.isIncrementallyUnusable(node)) {
// Didn't contain anything that would make it unusable. Awesome. This is
// a node we can reuse.
return node;
}
// We couldn't use currentNode. Try to move to its first child (in case that's a
// node). If it is we can try using that. Otherwise we'll just bail out in the
// next iteration of the loop.
oldSourceUnitCursor.moveToFirstChild();
}
}
function canReuseTokenFromOldSourceUnit(token: ISyntaxToken): boolean {
// A token is safe to return if:
// a) it did not intersect the change range.
// b) it does not contain skipped text.
// c) it is not zero width.
// d) it is not a contextual parser token.
//
// NOTE: It is safe to get a token regardless of what our strict context was/is. That's
// because the strict context doesn't change what tokens are scanned, only how the
// parser reacts to them.
//
// NOTE: we don't mark a keyword that was converted to an identifier as 'incrementally
// unusable. This is because we don't want to mark it's containing parent node as
// unusable. i.e. if i have this: "public Foo(string: Type) { }", then that *entire* node
// is reusuable even though "string" was converted to an identifier. However, we still
// need to make sure that if that the parser asks for a *token* we don't return it.
// Converted identifiers can't ever be created by the scanner, and as such, should not
// be returned by this source.
return token &&
!(<ISyntaxElementInternal><ISyntaxElement>token).intersectsChange &&
!token.isIncrementallyUnusable() &&
!Scanner.isContextualToken(token);
}
function tryGetTokenFromOldSourceUnit(): ISyntaxToken {
// get the current token that the cursor is pointing at.
var token = oldSourceUnitCursor.currentToken();
return canReuseTokenFromOldSourceUnit(token) ? token : undefined;
}
function peekToken(n: number): ISyntaxToken {
if (trySynchronizeCursorToPosition()) {
var token = tryPeekTokenFromOldSourceUnit(n);
if (token) {
return token;
}
}
// Couldn't peek this far in the old tree. Get the token from the new text.
return scannerParserSource.peekToken(n);
}
function tryPeekTokenFromOldSourceUnit(n: number): ISyntaxToken {
// clone the existing cursor so we can move it forward and then restore ourselves back
// to where we started from.
var cursorClone = cloneSyntaxCursor(oldSourceUnitCursor);
var token = tryPeekTokenFromOldSourceUnitWorker(n);
returnSyntaxCursor(oldSourceUnitCursor);
oldSourceUnitCursor = cursorClone;
return token;
}
function tryPeekTokenFromOldSourceUnitWorker(n: number): ISyntaxToken {
// First, make sure the cursor is pointing at a token.
oldSourceUnitCursor.moveToFirstToken();
// Now, keep walking forward to successive tokens.
for (var i = 0; i < n; i++) {
var interimToken = oldSourceUnitCursor.currentToken();
if (!canReuseTokenFromOldSourceUnit(interimToken)) {
return undefined;
}
oldSourceUnitCursor.moveToNextSibling();
}
var token = oldSourceUnitCursor.currentToken();
return canReuseTokenFromOldSourceUnit(token) ? token : undefined;
}
function consumeNodeOrToken(nodeOrToken: ISyntaxNodeOrToken): void {
scannerParserSource.consumeNodeOrToken(nodeOrToken);
}
return {
text: text,
fileName: oldSyntaxTree.fileName(),
languageVersion: oldSyntaxTree.languageVersion(),
absolutePosition: absolutePosition,
currentNode: currentNode,
currentToken: currentToken,
currentContextualToken: currentContextualToken,
peekToken: peekToken,
consumeNodeOrToken: scannerParserSource.consumeNodeOrToken,
tryParse: tryParse,
diagnostics: diagnostics
};
}
function updateTokenPositionsAndMarkElements(element: ISyntaxElement, changeStart: number, changeRangeOldEnd: number, delta: number, fullStart: number): void {
// First, try to skip past any elements that we dont' need to move. We don't need to
// move any elements that don't start after the end of the change range.
if (fullStart > changeRangeOldEnd) {
// Note, we only move elements that are truly after the end of the change range.
// We consider elements that are touching the end of the change range to be unusable.
forceUpdateTokenPositionsForElement(element, delta);
}
else {
// Check if the element intersects the change range. If it does, then it is not
// reusable. Also, we'll need to recurse to see what constituent portions we may
// be able to use.
var fullEnd = fullStart + fullWidth(element);
if (fullEnd >= changeStart) {
(<ISyntaxElementInternal>element).intersectsChange = true;
if (isList(element)) {
var list = <ISyntaxNodeOrToken[]>element;
for (var i = 0, n = list.length; i < n; i++) {
var child: ISyntaxElement = list[i];
updateTokenPositionsAndMarkElements(child, changeStart, changeRangeOldEnd, delta, fullStart);
fullStart += fullWidth(child);
}
}
else if (isNode(element)) {
var node = <ISyntaxNode>element;
for (var i = 0, n = node.childCount; i < n; i++) {
var child = node.childAt(i);
if (child) {
updateTokenPositionsAndMarkElements(child, changeStart, changeRangeOldEnd, delta, fullStart);
fullStart += fullWidth(child);
}
}
}
}
// else {
// This element ended strictly before the edited range. We don't need to do anything
// with it.
// }
}
}
function forceUpdateTokenPositionsForElement(element: ISyntaxElement, delta: number) {
// No need to move anything if the delta is 0.
if (delta !== 0) {
if (isList(element)) {
var list = <ISyntaxNodeOrToken[]>element;
for (var i = 0, n = list.length; i < n; i++) {
forceUpdateTokenPositionForNodeOrToken(list[i], delta);
}
}
else {
forceUpdateTokenPositionForNodeOrToken(<ISyntaxNodeOrToken>element, delta);
}
}
}
function forceUpdateTokenPosition(token: ISyntaxToken, delta: number) {
token.setFullStart(token.fullStart() + delta);
}
function forceUpdateTokenPositionForNodeOrToken(nodeOrToken: ISyntaxNodeOrToken, delta: number) {
if (isToken(nodeOrToken)) {
forceUpdateTokenPosition(<ISyntaxToken>nodeOrToken, delta);
}
else {
var tokens = getTokens(<ISyntaxNode>nodeOrToken);
for (var i = 0, n = tokens.length; i < n; i++) {
forceUpdateTokenPosition(tokens[i], delta);
}
}
}
export function parse(oldSyntaxTree: SyntaxTree, textChangeRange: TextChangeRange, newText: ISimpleText): SyntaxTree {
if (textChangeRange.isUnchanged()) {
return oldSyntaxTree;
}
return Parser.parseSource(createParserSource(oldSyntaxTree, textChangeRange, newText), oldSyntaxTree.isDeclaration());
}
}

View file

@ -1,3 +0,0 @@
module TypeScript {
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,50 +0,0 @@
///<reference path='..\text\references.ts' />
///<reference path='characterInfo.ts' />
///<reference path='constants.ts' />
///<reference path='formattingOptions.ts' />
// ///<reference path='indentation.ts' />
///<reference path='languageVersion.ts' />
// Scanner depends on SyntaxKind and SyntaxFacts
///<reference path='syntaxKind.ts' />
///<reference path='syntaxFacts.ts' />
///<reference path='scannerUtilities.generated.ts' />
///<reference path='scanner.ts' />
///<reference path='slidingWindow.ts' />
///<reference path='syntax.ts' />
///<reference path='syntaxElement.ts' />
///<reference path='syntaxFacts2.ts' />
///<reference path='syntaxList.ts' />
///<reference path='syntaxNodeOrToken.ts' />
// SyntaxDedenter depends on SyntaxRewriter
// ///<reference path='syntaxDedenter.ts' />
// SyntaxIndenter depends on SyntaxRewriter
// ///<reference path='syntaxIndenter.ts' />
///<reference path='syntaxToken.ts' />
///<reference path='syntaxTrivia.ts' />
///<reference path='syntaxTriviaList.ts' />
///<reference path='syntaxVisitor.generated.ts' />
///<reference path='syntaxWalker.generated.ts' />
// SyntaxInformationMap depends on SyntaxWalker
// ///<reference path='syntaxNodeInvariantsChecker.ts' />
// SyntaxUtilities depends on SyntaxWalker
///<reference path='syntaxUtilities.ts' />
///<reference path='parser.ts' />
// Concrete nodes depend on the parser.
///<reference path='syntaxInterfaces.generated.ts' />
///<reference path='syntaxNodes.concrete.generated.ts' />
// SyntaxTree depends on PositionTrackingWalker
///<reference path='syntaxTree.ts' />
///<reference path='unicode.ts' />
///<reference path='syntaxCursor.ts' />
///<reference path='incrementalParser.ts' />

File diff suppressed because it is too large Load diff

View file

@ -1,150 +0,0 @@
///<reference path='references.ts' />
module TypeScript {
export module ScannerUtilities {
export 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, 5, 5, 7, 11, 7, 3, 6, 7, 6, 3, 4, 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];
export function identifierKind(str: string, start: number, length: number): SyntaxKind {
switch (length) {
case 2: // do, if, in
switch(str.charCodeAt(start)) {
case CharacterCodes.d: return (str.charCodeAt(start + 1) === CharacterCodes.o) ? SyntaxKind.DoKeyword : SyntaxKind.IdentifierName;
case CharacterCodes.i: // if, in
switch(str.charCodeAt(start + 1)) {
case CharacterCodes.f: return SyntaxKind.IfKeyword;
case CharacterCodes.n: return SyntaxKind.InKeyword;
default: return SyntaxKind.IdentifierName;
}
default: return SyntaxKind.IdentifierName;
}
case 3: // any, for, get, let, new, set, try, var
switch(str.charCodeAt(start)) {
case CharacterCodes.a: return (str.charCodeAt(start + 1) === CharacterCodes.n && str.charCodeAt(start + 2) === CharacterCodes.y) ? SyntaxKind.AnyKeyword : SyntaxKind.IdentifierName;
case CharacterCodes.f: return (str.charCodeAt(start + 1) === CharacterCodes.o && str.charCodeAt(start + 2) === CharacterCodes.r) ? SyntaxKind.ForKeyword : SyntaxKind.IdentifierName;
case CharacterCodes.g: return (str.charCodeAt(start + 1) === CharacterCodes.e && str.charCodeAt(start + 2) === CharacterCodes.t) ? SyntaxKind.GetKeyword : SyntaxKind.IdentifierName;
case CharacterCodes.l: return (str.charCodeAt(start + 1) === CharacterCodes.e && str.charCodeAt(start + 2) === CharacterCodes.t) ? SyntaxKind.LetKeyword : SyntaxKind.IdentifierName;
case CharacterCodes.n: return (str.charCodeAt(start + 1) === CharacterCodes.e && str.charCodeAt(start + 2) === CharacterCodes.w) ? SyntaxKind.NewKeyword : SyntaxKind.IdentifierName;
case CharacterCodes.s: return (str.charCodeAt(start + 1) === CharacterCodes.e && str.charCodeAt(start + 2) === CharacterCodes.t) ? SyntaxKind.SetKeyword : SyntaxKind.IdentifierName;
case CharacterCodes.t: return (str.charCodeAt(start + 1) === CharacterCodes.r && str.charCodeAt(start + 2) === CharacterCodes.y) ? SyntaxKind.TryKeyword : SyntaxKind.IdentifierName;
case CharacterCodes.v: return (str.charCodeAt(start + 1) === CharacterCodes.a && str.charCodeAt(start + 2) === CharacterCodes.r) ? SyntaxKind.VarKeyword : SyntaxKind.IdentifierName;
default: return SyntaxKind.IdentifierName;
}
case 4: // case, else, enum, null, this, true, type, void, with
switch(str.charCodeAt(start)) {
case CharacterCodes.c: return (str.charCodeAt(start + 1) === CharacterCodes.a && str.charCodeAt(start + 2) === CharacterCodes.s && str.charCodeAt(start + 3) === CharacterCodes.e) ? SyntaxKind.CaseKeyword : SyntaxKind.IdentifierName;
case CharacterCodes.e: // else, enum
switch(str.charCodeAt(start + 1)) {
case CharacterCodes.l: return (str.charCodeAt(start + 2) === CharacterCodes.s && str.charCodeAt(start + 3) === CharacterCodes.e) ? SyntaxKind.ElseKeyword : SyntaxKind.IdentifierName;
case CharacterCodes.n: return (str.charCodeAt(start + 2) === CharacterCodes.u && str.charCodeAt(start + 3) === CharacterCodes.m) ? SyntaxKind.EnumKeyword : SyntaxKind.IdentifierName;
default: return SyntaxKind.IdentifierName;
}
case CharacterCodes.n: return (str.charCodeAt(start + 1) === CharacterCodes.u && str.charCodeAt(start + 2) === CharacterCodes.l && str.charCodeAt(start + 3) === CharacterCodes.l) ? SyntaxKind.NullKeyword : SyntaxKind.IdentifierName;
case CharacterCodes.t: // this, true, type
switch(str.charCodeAt(start + 1)) {
case CharacterCodes.h: return (str.charCodeAt(start + 2) === CharacterCodes.i && str.charCodeAt(start + 3) === CharacterCodes.s) ? SyntaxKind.ThisKeyword : SyntaxKind.IdentifierName;
case CharacterCodes.r: return (str.charCodeAt(start + 2) === CharacterCodes.u && str.charCodeAt(start + 3) === CharacterCodes.e) ? SyntaxKind.TrueKeyword : SyntaxKind.IdentifierName;
case CharacterCodes.y: return (str.charCodeAt(start + 2) === CharacterCodes.p && str.charCodeAt(start + 3) === CharacterCodes.e) ? SyntaxKind.TypeKeyword : SyntaxKind.IdentifierName;
default: return SyntaxKind.IdentifierName;
}
case CharacterCodes.v: return (str.charCodeAt(start + 1) === CharacterCodes.o && str.charCodeAt(start + 2) === CharacterCodes.i && str.charCodeAt(start + 3) === CharacterCodes.d) ? SyntaxKind.VoidKeyword : SyntaxKind.IdentifierName;
case CharacterCodes.w: return (str.charCodeAt(start + 1) === CharacterCodes.i && str.charCodeAt(start + 2) === CharacterCodes.t && str.charCodeAt(start + 3) === CharacterCodes.h) ? SyntaxKind.WithKeyword : SyntaxKind.IdentifierName;
default: return SyntaxKind.IdentifierName;
}
case 5: // async, await, break, catch, class, const, false, super, throw, while, yield
switch(str.charCodeAt(start)) {
case CharacterCodes.a: // async, await
switch(str.charCodeAt(start + 1)) {
case CharacterCodes.s: return (str.charCodeAt(start + 2) === CharacterCodes.y && str.charCodeAt(start + 3) === CharacterCodes.n && str.charCodeAt(start + 4) === CharacterCodes.c) ? SyntaxKind.AsyncKeyword : SyntaxKind.IdentifierName;
case CharacterCodes.w: return (str.charCodeAt(start + 2) === CharacterCodes.a && str.charCodeAt(start + 3) === CharacterCodes.i && str.charCodeAt(start + 4) === CharacterCodes.t) ? SyntaxKind.AwaitKeyword : SyntaxKind.IdentifierName;
default: return SyntaxKind.IdentifierName;
}
case CharacterCodes.b: return (str.charCodeAt(start + 1) === CharacterCodes.r && str.charCodeAt(start + 2) === CharacterCodes.e && str.charCodeAt(start + 3) === CharacterCodes.a && str.charCodeAt(start + 4) === CharacterCodes.k) ? SyntaxKind.BreakKeyword : SyntaxKind.IdentifierName;
case CharacterCodes.c: // catch, class, const
switch(str.charCodeAt(start + 1)) {
case CharacterCodes.a: return (str.charCodeAt(start + 2) === CharacterCodes.t && str.charCodeAt(start + 3) === CharacterCodes.c && str.charCodeAt(start + 4) === CharacterCodes.h) ? SyntaxKind.CatchKeyword : SyntaxKind.IdentifierName;
case CharacterCodes.l: return (str.charCodeAt(start + 2) === CharacterCodes.a && str.charCodeAt(start + 3) === CharacterCodes.s && str.charCodeAt(start + 4) === CharacterCodes.s) ? SyntaxKind.ClassKeyword : SyntaxKind.IdentifierName;
case CharacterCodes.o: return (str.charCodeAt(start + 2) === CharacterCodes.n && str.charCodeAt(start + 3) === CharacterCodes.s && str.charCodeAt(start + 4) === CharacterCodes.t) ? SyntaxKind.ConstKeyword : SyntaxKind.IdentifierName;
default: return SyntaxKind.IdentifierName;
}
case CharacterCodes.f: return (str.charCodeAt(start + 1) === CharacterCodes.a && str.charCodeAt(start + 2) === CharacterCodes.l && str.charCodeAt(start + 3) === CharacterCodes.s && str.charCodeAt(start + 4) === CharacterCodes.e) ? SyntaxKind.FalseKeyword : SyntaxKind.IdentifierName;
case CharacterCodes.s: return (str.charCodeAt(start + 1) === CharacterCodes.u && str.charCodeAt(start + 2) === CharacterCodes.p && str.charCodeAt(start + 3) === CharacterCodes.e && str.charCodeAt(start + 4) === CharacterCodes.r) ? SyntaxKind.SuperKeyword : SyntaxKind.IdentifierName;
case CharacterCodes.t: return (str.charCodeAt(start + 1) === CharacterCodes.h && str.charCodeAt(start + 2) === CharacterCodes.r && str.charCodeAt(start + 3) === CharacterCodes.o && str.charCodeAt(start + 4) === CharacterCodes.w) ? SyntaxKind.ThrowKeyword : SyntaxKind.IdentifierName;
case CharacterCodes.w: return (str.charCodeAt(start + 1) === CharacterCodes.h && str.charCodeAt(start + 2) === CharacterCodes.i && str.charCodeAt(start + 3) === CharacterCodes.l && str.charCodeAt(start + 4) === CharacterCodes.e) ? SyntaxKind.WhileKeyword : SyntaxKind.IdentifierName;
case CharacterCodes.y: return (str.charCodeAt(start + 1) === CharacterCodes.i && str.charCodeAt(start + 2) === CharacterCodes.e && str.charCodeAt(start + 3) === CharacterCodes.l && str.charCodeAt(start + 4) === CharacterCodes.d) ? SyntaxKind.YieldKeyword : SyntaxKind.IdentifierName;
default: return SyntaxKind.IdentifierName;
}
case 6: // delete, export, import, module, number, public, return, static, string, switch, typeof
switch(str.charCodeAt(start)) {
case CharacterCodes.d: return (str.charCodeAt(start + 1) === CharacterCodes.e && str.charCodeAt(start + 2) === CharacterCodes.l && str.charCodeAt(start + 3) === CharacterCodes.e && str.charCodeAt(start + 4) === CharacterCodes.t && str.charCodeAt(start + 5) === CharacterCodes.e) ? SyntaxKind.DeleteKeyword : SyntaxKind.IdentifierName;
case CharacterCodes.e: return (str.charCodeAt(start + 1) === CharacterCodes.x && str.charCodeAt(start + 2) === CharacterCodes.p && str.charCodeAt(start + 3) === CharacterCodes.o && str.charCodeAt(start + 4) === CharacterCodes.r && str.charCodeAt(start + 5) === CharacterCodes.t) ? SyntaxKind.ExportKeyword : SyntaxKind.IdentifierName;
case CharacterCodes.i: return (str.charCodeAt(start + 1) === CharacterCodes.m && str.charCodeAt(start + 2) === CharacterCodes.p && str.charCodeAt(start + 3) === CharacterCodes.o && str.charCodeAt(start + 4) === CharacterCodes.r && str.charCodeAt(start + 5) === CharacterCodes.t) ? SyntaxKind.ImportKeyword : SyntaxKind.IdentifierName;
case CharacterCodes.m: return (str.charCodeAt(start + 1) === CharacterCodes.o && str.charCodeAt(start + 2) === CharacterCodes.d && str.charCodeAt(start + 3) === CharacterCodes.u && str.charCodeAt(start + 4) === CharacterCodes.l && str.charCodeAt(start + 5) === CharacterCodes.e) ? SyntaxKind.ModuleKeyword : SyntaxKind.IdentifierName;
case CharacterCodes.n: return (str.charCodeAt(start + 1) === CharacterCodes.u && str.charCodeAt(start + 2) === CharacterCodes.m && str.charCodeAt(start + 3) === CharacterCodes.b && str.charCodeAt(start + 4) === CharacterCodes.e && str.charCodeAt(start + 5) === CharacterCodes.r) ? SyntaxKind.NumberKeyword : SyntaxKind.IdentifierName;
case CharacterCodes.p: return (str.charCodeAt(start + 1) === CharacterCodes.u && str.charCodeAt(start + 2) === CharacterCodes.b && str.charCodeAt(start + 3) === CharacterCodes.l && str.charCodeAt(start + 4) === CharacterCodes.i && str.charCodeAt(start + 5) === CharacterCodes.c) ? SyntaxKind.PublicKeyword : SyntaxKind.IdentifierName;
case CharacterCodes.r: return (str.charCodeAt(start + 1) === CharacterCodes.e && str.charCodeAt(start + 2) === CharacterCodes.t && str.charCodeAt(start + 3) === CharacterCodes.u && str.charCodeAt(start + 4) === CharacterCodes.r && str.charCodeAt(start + 5) === CharacterCodes.n) ? SyntaxKind.ReturnKeyword : SyntaxKind.IdentifierName;
case CharacterCodes.s: // static, string, switch
switch(str.charCodeAt(start + 1)) {
case CharacterCodes.t: // static, string
switch(str.charCodeAt(start + 2)) {
case CharacterCodes.a: return (str.charCodeAt(start + 3) === CharacterCodes.t && str.charCodeAt(start + 4) === CharacterCodes.i && str.charCodeAt(start + 5) === CharacterCodes.c) ? SyntaxKind.StaticKeyword : SyntaxKind.IdentifierName;
case CharacterCodes.r: return (str.charCodeAt(start + 3) === CharacterCodes.i && str.charCodeAt(start + 4) === CharacterCodes.n && str.charCodeAt(start + 5) === CharacterCodes.g) ? SyntaxKind.StringKeyword : SyntaxKind.IdentifierName;
default: return SyntaxKind.IdentifierName;
}
case CharacterCodes.w: return (str.charCodeAt(start + 2) === CharacterCodes.i && str.charCodeAt(start + 3) === CharacterCodes.t && str.charCodeAt(start + 4) === CharacterCodes.c && str.charCodeAt(start + 5) === CharacterCodes.h) ? SyntaxKind.SwitchKeyword : SyntaxKind.IdentifierName;
default: return SyntaxKind.IdentifierName;
}
case CharacterCodes.t: return (str.charCodeAt(start + 1) === CharacterCodes.y && str.charCodeAt(start + 2) === CharacterCodes.p && str.charCodeAt(start + 3) === CharacterCodes.e && str.charCodeAt(start + 4) === CharacterCodes.o && str.charCodeAt(start + 5) === CharacterCodes.f) ? SyntaxKind.TypeOfKeyword : SyntaxKind.IdentifierName;
default: return SyntaxKind.IdentifierName;
}
case 7: // boolean, declare, default, extends, finally, package, private, require
switch(str.charCodeAt(start)) {
case CharacterCodes.b: return (str.charCodeAt(start + 1) === CharacterCodes.o && str.charCodeAt(start + 2) === CharacterCodes.o && str.charCodeAt(start + 3) === CharacterCodes.l && str.charCodeAt(start + 4) === CharacterCodes.e && str.charCodeAt(start + 5) === CharacterCodes.a && str.charCodeAt(start + 6) === CharacterCodes.n) ? SyntaxKind.BooleanKeyword : SyntaxKind.IdentifierName;
case CharacterCodes.d: // declare, default
switch(str.charCodeAt(start + 1)) {
case CharacterCodes.e: // declare, default
switch(str.charCodeAt(start + 2)) {
case CharacterCodes.c: return (str.charCodeAt(start + 3) === CharacterCodes.l && str.charCodeAt(start + 4) === CharacterCodes.a && str.charCodeAt(start + 5) === CharacterCodes.r && str.charCodeAt(start + 6) === CharacterCodes.e) ? SyntaxKind.DeclareKeyword : SyntaxKind.IdentifierName;
case CharacterCodes.f: return (str.charCodeAt(start + 3) === CharacterCodes.a && str.charCodeAt(start + 4) === CharacterCodes.u && str.charCodeAt(start + 5) === CharacterCodes.l && str.charCodeAt(start + 6) === CharacterCodes.t) ? SyntaxKind.DefaultKeyword : SyntaxKind.IdentifierName;
default: return SyntaxKind.IdentifierName;
}
default: return SyntaxKind.IdentifierName;
}
case CharacterCodes.e: return (str.charCodeAt(start + 1) === CharacterCodes.x && str.charCodeAt(start + 2) === CharacterCodes.t && str.charCodeAt(start + 3) === CharacterCodes.e && str.charCodeAt(start + 4) === CharacterCodes.n && str.charCodeAt(start + 5) === CharacterCodes.d && str.charCodeAt(start + 6) === CharacterCodes.s) ? SyntaxKind.ExtendsKeyword : SyntaxKind.IdentifierName;
case CharacterCodes.f: return (str.charCodeAt(start + 1) === CharacterCodes.i && str.charCodeAt(start + 2) === CharacterCodes.n && str.charCodeAt(start + 3) === CharacterCodes.a && str.charCodeAt(start + 4) === CharacterCodes.l && str.charCodeAt(start + 5) === CharacterCodes.l && str.charCodeAt(start + 6) === CharacterCodes.y) ? SyntaxKind.FinallyKeyword : SyntaxKind.IdentifierName;
case CharacterCodes.p: // package, private
switch(str.charCodeAt(start + 1)) {
case CharacterCodes.a: return (str.charCodeAt(start + 2) === CharacterCodes.c && str.charCodeAt(start + 3) === CharacterCodes.k && str.charCodeAt(start + 4) === CharacterCodes.a && str.charCodeAt(start + 5) === CharacterCodes.g && str.charCodeAt(start + 6) === CharacterCodes.e) ? SyntaxKind.PackageKeyword : SyntaxKind.IdentifierName;
case CharacterCodes.r: return (str.charCodeAt(start + 2) === CharacterCodes.i && str.charCodeAt(start + 3) === CharacterCodes.v && str.charCodeAt(start + 4) === CharacterCodes.a && str.charCodeAt(start + 5) === CharacterCodes.t && str.charCodeAt(start + 6) === CharacterCodes.e) ? SyntaxKind.PrivateKeyword : SyntaxKind.IdentifierName;
default: return SyntaxKind.IdentifierName;
}
case CharacterCodes.r: return (str.charCodeAt(start + 1) === CharacterCodes.e && str.charCodeAt(start + 2) === CharacterCodes.q && str.charCodeAt(start + 3) === CharacterCodes.u && str.charCodeAt(start + 4) === CharacterCodes.i && str.charCodeAt(start + 5) === CharacterCodes.r && str.charCodeAt(start + 6) === CharacterCodes.e) ? SyntaxKind.RequireKeyword : SyntaxKind.IdentifierName;
default: return SyntaxKind.IdentifierName;
}
case 8: // continue, debugger, function
switch(str.charCodeAt(start)) {
case CharacterCodes.c: return (str.charCodeAt(start + 1) === CharacterCodes.o && str.charCodeAt(start + 2) === CharacterCodes.n && str.charCodeAt(start + 3) === CharacterCodes.t && str.charCodeAt(start + 4) === CharacterCodes.i && str.charCodeAt(start + 5) === CharacterCodes.n && str.charCodeAt(start + 6) === CharacterCodes.u && str.charCodeAt(start + 7) === CharacterCodes.e) ? SyntaxKind.ContinueKeyword : SyntaxKind.IdentifierName;
case CharacterCodes.d: return (str.charCodeAt(start + 1) === CharacterCodes.e && str.charCodeAt(start + 2) === CharacterCodes.b && str.charCodeAt(start + 3) === CharacterCodes.u && str.charCodeAt(start + 4) === CharacterCodes.g && str.charCodeAt(start + 5) === CharacterCodes.g && str.charCodeAt(start + 6) === CharacterCodes.e && str.charCodeAt(start + 7) === CharacterCodes.r) ? SyntaxKind.DebuggerKeyword : SyntaxKind.IdentifierName;
case CharacterCodes.f: return (str.charCodeAt(start + 1) === CharacterCodes.u && str.charCodeAt(start + 2) === CharacterCodes.n && str.charCodeAt(start + 3) === CharacterCodes.c && str.charCodeAt(start + 4) === CharacterCodes.t && str.charCodeAt(start + 5) === CharacterCodes.i && str.charCodeAt(start + 6) === CharacterCodes.o && str.charCodeAt(start + 7) === CharacterCodes.n) ? SyntaxKind.FunctionKeyword : SyntaxKind.IdentifierName;
default: return SyntaxKind.IdentifierName;
}
case 9: // interface, protected
switch(str.charCodeAt(start)) {
case CharacterCodes.i: return (str.charCodeAt(start + 1) === CharacterCodes.n && str.charCodeAt(start + 2) === CharacterCodes.t && str.charCodeAt(start + 3) === CharacterCodes.e && str.charCodeAt(start + 4) === CharacterCodes.r && str.charCodeAt(start + 5) === CharacterCodes.f && str.charCodeAt(start + 6) === CharacterCodes.a && str.charCodeAt(start + 7) === CharacterCodes.c && str.charCodeAt(start + 8) === CharacterCodes.e) ? SyntaxKind.InterfaceKeyword : SyntaxKind.IdentifierName;
case CharacterCodes.p: return (str.charCodeAt(start + 1) === CharacterCodes.r && str.charCodeAt(start + 2) === CharacterCodes.o && str.charCodeAt(start + 3) === CharacterCodes.t && str.charCodeAt(start + 4) === CharacterCodes.e && str.charCodeAt(start + 5) === CharacterCodes.c && str.charCodeAt(start + 6) === CharacterCodes.t && str.charCodeAt(start + 7) === CharacterCodes.e && str.charCodeAt(start + 8) === CharacterCodes.d) ? SyntaxKind.ProtectedKeyword : SyntaxKind.IdentifierName;
default: return SyntaxKind.IdentifierName;
}
case 10: // implements, instanceof
switch(str.charCodeAt(start)) {
case CharacterCodes.i: // implements, instanceof
switch(str.charCodeAt(start + 1)) {
case CharacterCodes.m: return (str.charCodeAt(start + 2) === CharacterCodes.p && str.charCodeAt(start + 3) === CharacterCodes.l && str.charCodeAt(start + 4) === CharacterCodes.e && str.charCodeAt(start + 5) === CharacterCodes.m && str.charCodeAt(start + 6) === CharacterCodes.e && str.charCodeAt(start + 7) === CharacterCodes.n && str.charCodeAt(start + 8) === CharacterCodes.t && str.charCodeAt(start + 9) === CharacterCodes.s) ? SyntaxKind.ImplementsKeyword : SyntaxKind.IdentifierName;
case CharacterCodes.n: return (str.charCodeAt(start + 2) === CharacterCodes.s && str.charCodeAt(start + 3) === CharacterCodes.t && str.charCodeAt(start + 4) === CharacterCodes.a && str.charCodeAt(start + 5) === CharacterCodes.n && str.charCodeAt(start + 6) === CharacterCodes.c && str.charCodeAt(start + 7) === CharacterCodes.e && str.charCodeAt(start + 8) === CharacterCodes.o && str.charCodeAt(start + 9) === CharacterCodes.f) ? SyntaxKind.InstanceOfKeyword : SyntaxKind.IdentifierName;
default: return SyntaxKind.IdentifierName;
}
default: return SyntaxKind.IdentifierName;
}
case 11: return (str.charCodeAt(start) === CharacterCodes.c && str.charCodeAt(start + 1) === CharacterCodes.o && str.charCodeAt(start + 2) === CharacterCodes.n && str.charCodeAt(start + 3) === CharacterCodes.s && str.charCodeAt(start + 4) === CharacterCodes.t && str.charCodeAt(start + 5) === CharacterCodes.r && str.charCodeAt(start + 6) === CharacterCodes.u && str.charCodeAt(start + 7) === CharacterCodes.c && str.charCodeAt(start + 8) === CharacterCodes.t && str.charCodeAt(start + 9) === CharacterCodes.o && str.charCodeAt(start + 10) === CharacterCodes.r) ? SyntaxKind.ConstructorKeyword : SyntaxKind.IdentifierName;
default: return SyntaxKind.IdentifierName;
}
}
}
}

View file

@ -1,197 +0,0 @@
///<reference path='references.ts' />
module TypeScript {
export interface ISlidingWindowSource {
// Asks the source to copy items starting at sourceIndex into the window at 'destinationIndex'
// with up to 'spaceAvailable' items. The actual number of items fetched should be given as
// the return value.
(argument: any): any;
}
export class SlidingWindow {
// The number of valid items in window.
public windowCount: number = 0;
// The *absolute* index in the *full* array of items the *window* array starts at. i.e.
// if there were 100 items, and window contains tokens [70, 80), then this value would be
// 70.
public windowAbsoluteStartIndex: number = 0;
// The index in the window array that we're at. i.e. if there 100 items and
// window contains tokens [70, 80), and we're on item 75, then this value would be '5'.
// Note: it is not absolute. It is relative to the start of the window.
public currentRelativeItemIndex: number = 0;
// The number of pinned points there are. As long as there is at least one pinned point, we
// will not advance the start of the window array past the item marked by that pin point.
private _pinCount: number = 0;
// If there are any outstanding rewind points, this is index in the full array of items
// that the first rewind point points to. If this is not -1, then we will not shift the
// start of the items array past this point.
private firstPinnedAbsoluteIndex: number = -1;
constructor(// Underlying source that we retrieve items from.
private fetchNextItem: ISlidingWindowSource,
// A window of items that has been read in from the underlying source.
public window: any[],
// The default value to return when there are no more items left in the window.
private defaultValue: any,
// The length of the source we're reading from if we know it up front. -1 if we do not.
private sourceLength = -1) {
}
private addMoreItemsToWindow(argument: any): boolean {
var sourceLength = this.sourceLength;
if (sourceLength >= 0 && this.absoluteIndex() >= sourceLength) {
return false;
}
// First, make room for the new items if we're out of room.
if (this.windowCount >= this.window.length) {
this.tryShiftOrGrowWindow();
}
var item = this.fetchNextItem(argument);
this.window[this.windowCount] = item;
// Assert disabled because it is actually expensive enugh to affect perf.
this.windowCount++;
return true;
}
private tryShiftOrGrowWindow(): void {
// We want to shift if our current item is past the halfway point of the current item window.
var currentIndexIsPastWindowHalfwayPoint = this.currentRelativeItemIndex > (this.window.length >>> 1);
// However, we can only shift if we have no outstanding rewind points. Or, if we have an
// outstanding rewind point, that it points to some point after the start of the window.
var isAllowedToShift =
this.firstPinnedAbsoluteIndex === -1 ||
this.firstPinnedAbsoluteIndex > this.windowAbsoluteStartIndex;
if (currentIndexIsPastWindowHalfwayPoint && isAllowedToShift) {
// Figure out where we're going to start shifting from. If we have no oustanding rewind
// points, then we'll start shifting over all the items starting from the current
// token we're point out. Otherwise, we'll shift starting from the first item that
// the rewind point is pointing at.
//
// We'll call that point 'N' from now on.
var shiftStartIndex = this.firstPinnedAbsoluteIndex === -1
? this.currentRelativeItemIndex
: this.firstPinnedAbsoluteIndex - this.windowAbsoluteStartIndex;
// We have to shift the number of elements between the start index and the number of
// items in the window.
var shiftCount = this.windowCount - shiftStartIndex;
// Debug.assert(shiftStartIndex > 0);
if (shiftCount > 0) {
ArrayUtilities.copy(this.window, shiftStartIndex, this.window, 0, shiftCount);
}
// The window has now moved over to the right by N.
this.windowAbsoluteStartIndex += shiftStartIndex;
// The number of valid items in the window has now decreased by N.
this.windowCount -= shiftStartIndex;
// The current item now starts further to the left in the window.
this.currentRelativeItemIndex -= shiftStartIndex;
}
else {
// Grow the exisitng array.
// this.window[this.window.length * 2 - 1] = this.defaultValue;
ArrayUtilities.grow(this.window, this.window.length * 2, this.defaultValue);
}
}
public absoluteIndex(): number {
return this.windowAbsoluteStartIndex + this.currentRelativeItemIndex;
}
public isAtEndOfSource(): boolean {
return this.absoluteIndex() >= this.sourceLength;
}
public getAndPinAbsoluteIndex(): number {
// Find the absolute index of this pin point. i.e. it's the index as if we had an
// array containing *all* tokens.
var absoluteIndex = this.absoluteIndex();
var pinCount = this._pinCount++;
if (pinCount === 0) {
// If this is the first pinned point, then store off this index. We will ensure that
// we never shift the window past this point.
this.firstPinnedAbsoluteIndex = absoluteIndex;
}
return absoluteIndex;
}
public releaseAndUnpinAbsoluteIndex(absoluteIndex: number) {
this._pinCount--;
if (this._pinCount === 0) {
// If we just released the last outstanding pin, then we no longer need to 'fix' the
// token window so it can't move forward. Set the index to -1 so that we can shift
// things over the next time we read past the end of the array.
this.firstPinnedAbsoluteIndex = -1;
}
}
public rewindToPinnedIndex(absoluteIndex: number): void {
// The rewind point shows which absolute item we want to rewind to. Get the relative
// index in the actual array that we want to point to.
var relativeIndex = absoluteIndex - this.windowAbsoluteStartIndex;
// Make sure we haven't screwed anything up.
// Debug.assert(relativeIndex >= 0 && relativeIndex < this.windowCount);
// Set ourselves back to that point.
this.currentRelativeItemIndex = relativeIndex;
}
public currentItem(argument: any): any {
if (this.currentRelativeItemIndex >= this.windowCount) {
if (!this.addMoreItemsToWindow(argument)) {
return this.defaultValue;
}
}
return this.window[this.currentRelativeItemIndex];
}
public currentItemWithoutFetching(): any {
if (this.currentRelativeItemIndex >= this.windowCount) {
return undefined;
}
return this.window[this.currentRelativeItemIndex];
}
public peekItemN(n: number): any {
// Assert disabled because it is actually expensive enugh to affect perf.
// Debug.assert(n >= 0);
while (this.currentRelativeItemIndex + n >= this.windowCount) {
if (!this.addMoreItemsToWindow(/*argument:*/ undefined)) {
return this.defaultValue;
}
}
return this.window[this.currentRelativeItemIndex + n];
}
public moveToNextItem(): void {
this.currentRelativeItemIndex++;
}
public disgardAllItemsFromCurrentIndexOnwards(): void {
// By setting the window count to the current relative offset, we are effectively making
// any items we added to the window from the current offset onwards unusable. When we
// try to get the next item, we'll be forced to refetch them from the underlying source.
this.windowCount = this.currentRelativeItemIndex;
}
}
}

View file

@ -1,140 +0,0 @@
///<reference path='references.ts' />
module TypeScript.Syntax {
export var _nextSyntaxID: number = 1;
export function nodeHasSkippedOrMissingTokens(node: ISyntaxNode): boolean {
for (var i = 0; i < childCount(node); i++) {
var child = childAt(node, i);
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.hasLeadingSkippedToken() || (fullWidth(token) === 0 && token.kind !== SyntaxKind.EndOfFileToken)) {
return true;
}
}
}
return false;
}
export function isUnterminatedStringLiteral(token: ISyntaxToken): boolean {
if (token && token.kind === SyntaxKind.StringLiteral) {
var text = token.text();
return text.length < 2 || text.charCodeAt(text.length - 1) !== text.charCodeAt(0);
}
return false;
}
export function isUnterminatedMultilineCommentTrivia(trivia: ISyntaxTrivia): boolean {
if (trivia && trivia.kind === SyntaxKind.MultiLineCommentTrivia) {
var text = trivia.fullText();
return text.length < 4 || text.substring(text.length - 2) !== "*/";
}
return false;
}
export function isEntirelyInsideCommentTrivia(trivia: ISyntaxTrivia, fullStart: number, position: number): boolean {
if (trivia && trivia.isComment() && position > fullStart) {
var end = fullStart + trivia.fullWidth();
if (position < end) {
return true;
}
else if (position === end) {
return trivia.kind === SyntaxKind.SingleLineCommentTrivia || isUnterminatedMultilineCommentTrivia(trivia);
}
}
return false;
}
export function getAncestorOfKind(positionedToken: ISyntaxElement, kind: SyntaxKind): ISyntaxElement {
while (positionedToken && positionedToken.parent) {
if (positionedToken.parent.kind === kind) {
return positionedToken.parent;
}
positionedToken = positionedToken.parent;
}
return undefined;
}
export function hasAncestorOfKind(positionedToken: ISyntaxElement, kind: SyntaxKind): boolean {
return !!getAncestorOfKind(positionedToken, kind);
}
export function isIntegerLiteral(expression: IExpressionSyntax): boolean {
if (expression) {
switch (expression.kind) {
case SyntaxKind.PrefixUnaryExpression:
var prefixExpr = <PrefixUnaryExpressionSyntax>expression;
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*.
expression = prefixExpr.operand;
return isToken(expression) && IntegerUtilities.isInteger((<ISyntaxToken>expression).text());
}
return false;
case SyntaxKind.NumericLiteral:
// If it doesn't have a + or -, then either an integer literal or a hex literal
// is acceptable.
var text = (<ISyntaxToken> expression).text();
return IntegerUtilities.isInteger(text) || IntegerUtilities.isHexInteger(text);
}
}
return false;
}
export function containingNode(element: ISyntaxElement): ISyntaxNode {
var current = element.parent;
while (current && !isNode(current)) {
current = current.parent;
}
return <ISyntaxNode>current;
}
export function findTokenOnLeft(sourceUnit: SourceUnitSyntax, position: number): ISyntaxToken {
var positionedToken = findToken(sourceUnit, position);
var _start = start(positionedToken);
// Position better fall within this token.
// Debug.assert(position >= positionedToken.fullStart());
// Debug.assert(position < positionedToken.fullEnd() || positionedToken.token().tokenKind === SyntaxKind.EndOfFileToken);
// if position is after the start of the token, then this token is the token on the left.
if (position > _start) {
return positionedToken;
}
// we're in the trivia before the start of the token. Need to return the previous token.
if (positionedToken.fullStart() === 0) {
// Already on the first token. Nothing before us.
return undefined;
}
return previousToken(positionedToken);
}
export function findCompleteTokenOnLeft(sourceUnit: SourceUnitSyntax, position: number): ISyntaxToken {
var positionedToken = findToken(sourceUnit, position);
// Position better fall within this token.
// Debug.assert(position >= positionedToken.fullStart());
// Debug.assert(position < positionedToken.fullEnd() || positionedToken.token().tokenKind === SyntaxKind.EndOfFileToken);
// if position is after the end of the token, then this token is the token on the left.
if (width(positionedToken) > 0 && position >= fullEnd(positionedToken)) {
return positionedToken;
}
return previousToken(positionedToken);
}
}

View file

@ -1,255 +0,0 @@
/// <reference path="references.ts" />
module TypeScript.IncrementalParser {
interface SyntaxCursorPiece {
element: ISyntaxElement;
indexInParent: number
}
function createSyntaxCursorPiece(element: ISyntaxElement, indexInParent: number) {
return { element: element, indexInParent: indexInParent };
}
// Pool syntax cursors so we don't churn too much memory when we need temporary cursors.
// i.e. when we're speculatively parsing, we can cheaply get a pooled cursor and then
// return it when we no longer need it.
var syntaxCursorPool: SyntaxCursor[] = [];
var syntaxCursorPoolCount: number = 0;
export function returnSyntaxCursor(cursor: SyntaxCursor): void {
// Make sure the cursor isn't holding onto any syntax elements. We don't want to leak
// them when we return the cursor to the pool.
cursor.clean();
syntaxCursorPool[syntaxCursorPoolCount] = cursor;
syntaxCursorPoolCount++;
}
export function getSyntaxCursor(): SyntaxCursor {
// Get an existing cursor from the pool if we have one. Or create a new one if we don't.
var cursor = syntaxCursorPoolCount > 0
? syntaxCursorPool[syntaxCursorPoolCount - 1]
: createSyntaxCursor();
if (syntaxCursorPoolCount > 0) {
// If we reused an existing cursor, take it out of the pool so no one else uses it.
syntaxCursorPoolCount--;
syntaxCursorPool[syntaxCursorPoolCount] = undefined;
}
return cursor;
}
export function cloneSyntaxCursor(cursor: SyntaxCursor): SyntaxCursor {
var newCursor = getSyntaxCursor();
// Make the new cursor a *deep* copy of the cursor passed in. This ensures each cursor can
// be moved without affecting the other.
newCursor.deepCopyFrom(cursor);
return newCursor;
}
interface SyntaxCursor {
pieces: SyntaxCursorPiece[];
clean(): void;
isFinished(): boolean;
moveToFirstChild(): void;
moveToFirstToken(): void;
moveToNextSibling(): void;
currentNodeOrToken(): ISyntaxNodeOrToken;
currentNode(): ISyntaxNode;
currentToken(): ISyntaxToken;
pushElement(element: ISyntaxElement, indexInParent: number): void;
deepCopyFrom(other: SyntaxCursor): void;
}
function createSyntaxCursor(): SyntaxCursor {
// Our list of path pieces. The piece pointed to by 'currentPieceIndex' must be a node or
// token. However, pieces earlier than that may point to list nodes.
//
// For perf we reuse pieces as much as possible. i.e. instead of popping items off the
// list, we just will change currentPieceIndex so we can reuse that piece later.
var pieces: SyntaxCursorPiece[] = [];
var currentPieceIndex: number = -1;
// Cleans up this cursor so that it doesn't have any references to actual syntax nodes.
// This sould be done before returning the cursor to the pool so that the Parser module
// doesn't unnecessarily keep old syntax trees alive.
function clean(): void {
for (var i = 0, n = pieces.length; i < n; i++) {
var piece = pieces[i];
if (piece.element === undefined) {
break;
}
piece.element = undefined;
piece.indexInParent = -1;
}
currentPieceIndex = -1;
}
// Makes this cursor into a deep copy of the cursor passed in.
function deepCopyFrom(other: SyntaxCursor): void {
for (var i = 0, n = other.pieces.length; i < n; i++) {
var piece = other.pieces[i];
if (piece.element === undefined) {
break;
}
pushElement(piece.element, piece.indexInParent);
}
}
function isFinished(): boolean {
return currentPieceIndex < 0;
}
function currentNodeOrToken(): ISyntaxNodeOrToken {
if (isFinished()) {
return undefined;
}
var result = pieces[currentPieceIndex].element;
// The current element must always be a node or a token.
return <ISyntaxNodeOrToken>result;
}
function currentNode(): ISyntaxNode {
var element = currentNodeOrToken();
return isNode(element) ? <ISyntaxNode>element : undefined;
}
function isEmptyList(element: ISyntaxElement) {
return isList(element) && (<ISyntaxNodeOrToken[]>element).length === 0;
}
function moveToFirstChild() {
var nodeOrToken = currentNodeOrToken();
if (nodeOrToken === undefined) {
return;
}
if (isToken(nodeOrToken)) {
// If we're already on a token, there's nothing to do.
return;
}
// Either the node has some existent child, then move to it. if it doesn't, then it's
// an empty node. Conceptually the first child of an empty node is really just the
// next sibling of the empty node.
for (var i = 0, n = childCount(nodeOrToken); i < n; i++) {
var child = childAt(nodeOrToken, i);
if (child && !isEmptyList(child)) {
// Great, we found a real child. Push that.
pushElement(child, /*indexInParent:*/ i);
// If it was a list, make sure we're pointing at its first element. We know we
// must have one because this is a non-shared list.
moveToFirstChildIfList();
return;
}
}
// This element must have been an empty node. Moving to its 'first child' is equivalent to just
// moving to the next sibling.
moveToNextSibling();
}
function moveToNextSibling(): void {
while (!isFinished()) {
// first look to our parent and see if it has a sibling of us that we can move to.
var currentPiece = pieces[currentPieceIndex];
var parent = currentPiece.element.parent;
// We start searching at the index one past our own index in the parent.
for (var i = currentPiece.indexInParent + 1, n = childCount(parent); i < n; i++) {
var sibling = childAt(parent, i);
if (sibling && !isEmptyList(sibling)) {
// We found a good sibling that we can move to. Just reuse our existing piece
// so we don't have to push/pop.
currentPiece.element = sibling;
currentPiece.indexInParent = i;
// The sibling might have been a list. Move to it's first child.
moveToFirstChildIfList();
return;
}
}
// Didn't have a sibling for this element. Go up to our parent and get its sibling.
// Clear the data from the old piece. We don't want to keep any elements around
// unintentionally.
currentPiece.element = undefined;
currentPiece.indexInParent = -1;
// Point at the parent. if we move past the top of the path, then we're finished.
currentPieceIndex--;
}
}
function moveToFirstChildIfList(): void {
var element = pieces[currentPieceIndex].element;
if (isList(element)) {
// We cannot ever get an empty list in our piece path. Empty lists are 'shared' and
// we make sure to filter that out before pushing any children.
pushElement(childAt(element, 0), /*indexInParent:*/ 0);
}
}
function pushElement(element: ISyntaxElement, indexInParent: number): void {
currentPieceIndex++;
// Reuse an existing piece if we have one. Otherwise, push a new piece to our list.
if (currentPieceIndex === pieces.length) {
pieces.push(createSyntaxCursorPiece(element, indexInParent));
}
else {
var piece = pieces[currentPieceIndex];
piece.element = element;
piece.indexInParent = indexInParent;
}
}
function moveToFirstToken(): void {
while (!isFinished()) {
var element = pieces[currentPieceIndex].element;
if (isNode(element)) {
moveToFirstChild();
continue;
}
return;
}
}
function currentToken(): ISyntaxToken {
moveToFirstToken();
var element = currentNodeOrToken();
return <ISyntaxToken>element;
}
return {
pieces: pieces,
clean: clean,
isFinished: isFinished,
moveToFirstChild: moveToFirstChild,
moveToFirstToken: moveToFirstToken,
moveToNextSibling: moveToNextSibling,
currentNodeOrToken: currentNodeOrToken,
currentNode: currentNode,
currentToken: currentToken,
pushElement: pushElement,
deepCopyFrom: deepCopyFrom
};
}
}

View file

@ -1,193 +0,0 @@
///<reference path='references.ts' />
module TypeScript {
export class SyntaxDedenter extends SyntaxRewriter {
private lastTriviaWasNewLine: boolean;
constructor(dedentFirstToken: boolean,
private dedentationAmount: number,
private minimumIndent: number,
private options: FormattingOptions) {
super();
this.lastTriviaWasNewLine = dedentFirstToken;
}
private abort(): void {
this.lastTriviaWasNewLine = false;
this.dedentationAmount = 0;
}
private isAborted(): boolean {
return this.dedentationAmount === 0;
}
public visitToken(token: ISyntaxToken): ISyntaxToken {
if (token.width() === 0) {
return token;
}
var result = token;
if (this.lastTriviaWasNewLine) {
// have to add our indentation to every line that this token hits.
result = token.withLeadingTrivia(this.dedentTriviaList(token.leadingTrivia()));
}
if (this.isAborted()) {
// If we've decided to stop dedenting. Then just return immediately.
return token;
}
this.lastTriviaWasNewLine = token.hasTrailingNewLine();
return result;
}
private dedentTriviaList(triviaList: ISyntaxTriviaList): ISyntaxTriviaList {
var result: ISyntaxTrivia[] = [];
var dedentNextWhitespace = true;
// Keep walking through all our trivia (as long as we haven't decided to stop dedenting).
// Adjust the indentation on any whitespace trivia at the start of a line, or any multi-line
// trivia that span multiple lines.
for (var i = 0, n = triviaList.count(); i < n && !this.isAborted(); i++) {
var trivia = triviaList.syntaxTriviaAt(i);
var dedentThisTrivia = dedentNextWhitespace;
dedentNextWhitespace = false;
if (dedentThisTrivia) {
if (trivia.kind() === SyntaxKind.WhitespaceTrivia) {
// We pass in if there was a following newline after this whitespace. If there
// is, then it's fine if we dedent this newline all the way to 0. Otherwise,
// if the whitespace is followed by something, then we need to determine how
// much of the whitespace we can remove. If we can't remove all that we want,
// we'll need to adjust the dedentAmount. And, if we can't remove at all, then
// we need to stop dedenting entirely.
var hasFollowingNewLine = (i < triviaList.count() - 1) &&
triviaList.syntaxTriviaAt(i + 1).kind() === SyntaxKind.NewLineTrivia;
result.push(this.dedentWhitespace(trivia, hasFollowingNewLine));
continue;
}
else if (trivia.kind() !== SyntaxKind.NewLineTrivia) {
// We wanted to dedent, but the trivia we're on isn't whitespace and wasn't a
// newline. That means that we have something like a comment at the beginning
// of the line that we can't dedent. And, if we can't dedent it, then we
// shouldn't dedent this token or any more tokens.
this.abort();
break;
}
}
if (trivia.kind() === SyntaxKind.MultiLineCommentTrivia) {
// This trivia may span multiple lines. If it does, we need to dedent each
// successive line of it until it terminates.
result.push(this.dedentMultiLineComment(trivia));
continue;
}
// All other trivia we just append to the list.
result.push(trivia);
if (trivia.kind() === SyntaxKind.NewLineTrivia) {
// We hit a newline processing the trivia. We need to add the indentation to the
// next line as well.
dedentNextWhitespace = true;
}
}
if (dedentNextWhitespace) {
// We hit a new line as the last trivia (or there was no trivia). We want to dedent
// the next trivia, but we can't (because the token starts at the start of the line).
// If we can't dedent this, then we shouldn't dedent anymore.
this.abort();
}
if (this.isAborted()) {
return triviaList;
}
return Syntax.triviaList(result);
}
private dedentSegment(segment: string, hasFollowingNewLineTrivia: boolean): string {
// Find the position of the first non whitespace character in the segment.
var firstNonWhitespacePosition = Indentation.firstNonWhitespacePosition(segment);
if (firstNonWhitespacePosition === segment.length) {
if (hasFollowingNewLineTrivia) {
// It was entirely whitespace trivia, with a newline after it. Just trim this down
// to an empty string.
return "";
}
}
else if (CharacterInfo.isLineTerminator(segment.charCodeAt(firstNonWhitespacePosition))) {
// It was entirely whitespace, with a newline after it. Just trim this down to
// the newline
return segment.substring(firstNonWhitespacePosition);
}
// It was whitespace without a newline following it. We need to try to dedent this a bit.
// Convert that position to a column.
var firstNonWhitespaceColumn = Indentation.columnForPositionInString(segment, firstNonWhitespacePosition, this.options);
// Find the new column we want the nonwhitespace text to start at. Ideally it would be
// whatever column it was minus the dedentation amount. However, we won't go below a
// specified minimum indent (hence, max(initial - dedentAmount, minIndent). *But* if
// the initial column was less than that minimum indent, then we'll keep it at that column.
// (hence min(initial, desired)).
var newFirstNonWhitespaceColumn =
MathPrototype.min(firstNonWhitespaceColumn,
MathPrototype.max(firstNonWhitespaceColumn - this.dedentationAmount, this.minimumIndent));
if (newFirstNonWhitespaceColumn === firstNonWhitespaceColumn) {
// We aren't able to detent this token. Abort what we're doing
this.abort();
return segment;
}
// Update the dedentation amount for all subsequent tokens we run into.
this.dedentationAmount = firstNonWhitespaceColumn - newFirstNonWhitespaceColumn;
Debug.assert(this.dedentationAmount >= 0);
// Compute an indentation string for that.
var indentationString = Indentation.indentationString(newFirstNonWhitespaceColumn, this.options);
// Join the new indentation and the original string without its indentation.
return indentationString + segment.substring(firstNonWhitespacePosition);
}
private dedentWhitespace(trivia: ISyntaxTrivia, hasFollowingNewLineTrivia: boolean): ISyntaxTrivia {
var newIndentation = this.dedentSegment(trivia.fullText(), hasFollowingNewLineTrivia);
return Syntax.whitespace(newIndentation);
}
private dedentMultiLineComment(trivia: ISyntaxTrivia): ISyntaxTrivia {
var segments = Syntax.splitMultiLineCommentTriviaIntoMultipleLines(trivia);
if (segments.length === 1) {
// If there was only one segment, then this wasn't multiline.
return trivia;
}
for (var i = 1; i < segments.length; i++) {
var segment = segments[i];
segments[i] = this.dedentSegment(segment, /*hasFollowingNewLineTrivia*/ false);
}
var result = segments.join("");
// Create a new trivia token out of the indented lines.
return Syntax.multiLineComment(result);
}
public static dedentNode<T extends ISyntaxNode>(node: T, dedentFirstToken: boolean, dedentAmount: number, minimumIndent: number, options: FormattingOptions): T {
var dedenter = new SyntaxDedenter(dedentFirstToken, dedentAmount, minimumIndent, options);
var result = node.accept(dedenter);
if (dedenter.isAborted()) {
// We failed to dedent a token in this node. Return the original node as is.
return node;
}
return result;
}
}
}

View file

@ -1,465 +0,0 @@
///<reference path='references.ts' />
module TypeScript {
export function syntaxTree(element: ISyntaxElement): SyntaxTree {
if (element) {
// Debug.assert(!isShared(element));
while (element) {
if (element.kind === SyntaxKind.SourceUnit) {
return (<SourceUnitSyntax>element).syntaxTree;
}
element = element.parent;
}
}
return undefined;
}
export function parserContextFlags(node: ISyntaxNode): ParserContextFlags {
var info = node.__data;
if (info === undefined) {
return 0;
}
return info & ParserContextFlags.Mask;
}
export function parsedInStrictModeContext(node: ISyntaxNode): boolean {
return (parserContextFlags(node) & ParserContextFlags.StrictMode) !== 0;
}
export function parsedInDisallowInContext(node: ISyntaxNode): boolean {
return (parserContextFlags(node) & ParserContextFlags.DisallowIn) !== 0;
}
export function parsedInYieldContext(node: ISyntaxNode): boolean {
return (parserContextFlags(node) & ParserContextFlags.Yield) !== 0;
}
export function parsedInGeneratorParameterContext(node: ISyntaxNode): boolean {
return (parserContextFlags(node) & ParserContextFlags.GeneratorParameter) !== 0;
}
export function parsedInAsyncContext(node: ISyntaxNode): boolean {
return (parserContextFlags(node) & ParserContextFlags.Async) !== 0;
}
export function previousToken(token: ISyntaxToken): ISyntaxToken {
var start = token.fullStart();
if (start === 0) {
return undefined;
}
return findToken(syntaxTree(token).sourceUnit(), start - 1);
}
/**
* Finds a token according to the following rules:
* 1) If position matches the End of the node/s FullSpan and the node is SourceUnitSyntax,
* then the EOF token is returned.
*
* 2) If node.FullSpan.Contains(position) then the token that contains given position is
* returned.
*
* 3) Otherwise an ArgumentOutOfRangeException is thrown
*
* Note: findToken will always return a non-missing token with width greater than or equal to
* 1 (except for EOF). Empty tokens synthesized by the parser are never returned.
*/
export function findToken(sourceUnit: SourceUnitSyntax, position: number): ISyntaxToken {
if (position < 0) {
throw Errors.argumentOutOfRange("position");
}
var token = findTokenInNodeOrToken(sourceUnit, 0, position);
if (token) {
Debug.assert(token.fullWidth() > 0);
return token;
}
if (position === fullWidth(sourceUnit)) {
return sourceUnit.endOfFileToken;
}
if (position > fullWidth(sourceUnit)) {
throw Errors.argumentOutOfRange("position");
}
throw Errors.invalidOperation();
}
function findTokenWorker(element: ISyntaxElement, elementPosition: number, position: number): ISyntaxToken {
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;
}
return undefined;
}
function findTokenInNodeOrToken(nodeOrToken: ISyntaxNodeOrToken, elementPosition: number, position: number): ISyntaxToken {
if (isToken(nodeOrToken)) {
return <ISyntaxToken>nodeOrToken;
}
for (var i = 0, n = childCount(nodeOrToken); i < n; i++) {
var child = nodeOrToken.childAt(i);
if (child) {
var childFullWidth = fullWidth(child);
var elementEndPosition = elementPosition + childFullWidth;
if (position < elementEndPosition) {
return findTokenWorker(child, elementPosition, position);
}
elementPosition = elementEndPosition;
}
}
return undefined;
}
function tryGetEndOfFileAt(element: ISyntaxElement, position: number): ISyntaxToken {
if (element.kind === SyntaxKind.SourceUnit && position === fullWidth(element)) {
var sourceUnit = <SourceUnitSyntax>element;
return sourceUnit.endOfFileToken;
}
return undefined;
}
export function nextToken(token: ISyntaxToken, text?: ISimpleText): ISyntaxToken {
if (token.kind === SyntaxKind.EndOfFileToken) {
return undefined;
}
return findToken(syntaxTree(token).sourceUnit(), fullEnd(token));
}
export function isNode(element: ISyntaxElement): boolean {
if (element) {
var kind = element.kind;
return kind >= SyntaxKind.FirstNode && kind <= SyntaxKind.LastNode;
}
return false;
}
function isTokenKind(kind: SyntaxKind) {
return kind >= SyntaxKind.FirstToken && kind <= SyntaxKind.LastToken
}
export function isToken(element: ISyntaxElement): boolean {
if (element) {
return isTokenKind(element.kind);
}
return false;
}
export function isList(element: ISyntaxElement): boolean {
return element instanceof Array;
}
export function syntaxID(element: ISyntaxElement): number {
//if (isShared(element)) {
// throw Errors.invalidOperation("Should not use shared syntax element as a key.");
//}
var obj = <any>element;
if (obj._syntaxID === undefined) {
obj._syntaxID = TypeScript.Syntax._nextSyntaxID++;
}
return obj._syntaxID;
}
function collectTextElements(element: ISyntaxElement, elements: string[], text: ISimpleText): void {
if (element) {
if (isToken(element)) {
elements.push((<ISyntaxToken>element).fullText(text));
}
else {
for (var i = 0, n = childCount(element); i < n; i++) {
collectTextElements(childAt(element, i), elements, text);
}
}
}
}
export function fullText(element: ISyntaxElement, text?: ISimpleText): string {
if (isToken(element)) {
return (<ISyntaxToken>element).fullText(text);
}
var elements: string[] = [];
collectTextElements(element, elements, text);
return elements.join("");
}
export function leadingTriviaWidth(element: ISyntaxElement, text?: ISimpleText): number {
var token = firstToken(element);
return token ? token.leadingTriviaWidth(text) : 0;
}
export function firstToken(element: ISyntaxElement): ISyntaxToken {
if (element) {
var kind = element.kind;
if (isTokenKind(kind)) {
return (<ISyntaxToken>element).fullWidth() > 0 || kind === SyntaxKind.EndOfFileToken ? <ISyntaxToken>element : undefined;
}
for (var i = 0, n = childCount(element); i < n; i++) {
var token = firstToken(childAt(element, i));
if (token) {
return token;
}
}
}
return undefined;
}
export function lastToken(element: ISyntaxElement): ISyntaxToken {
if (isToken(element)) {
return fullWidth(element) > 0 || element.kind === SyntaxKind.EndOfFileToken ? <ISyntaxToken>element : undefined;
}
if (element.kind === SyntaxKind.SourceUnit) {
return (<SourceUnitSyntax>element).endOfFileToken;
}
for (var i = childCount(element) - 1; i >= 0; i--) {
var child = childAt(element, i);
if (child) {
var token = lastToken(child);
if (token) {
return token;
}
}
}
return undefined;
}
export function fullStart(element: ISyntaxElement): number {
// Debug.assert(!isShared(element));
var token = isToken(element) ? <ISyntaxToken>element : firstToken(element);
return token ? token.fullStart() : -1;
}
export function fullWidth(element: ISyntaxElement): number {
if (isToken(element)) {
return (<ISyntaxToken>element).fullWidth();
}
var info = data(element);
return (info / SyntaxNodeConstants.FullWidthShift) | 0;
}
export function isIncrementallyUnusable(element: ISyntaxElement): boolean {
if (isToken(element)) {
return (<ISyntaxToken>element).isIncrementallyUnusable();
}
return (data(element) & SyntaxNodeConstants.IncrementallyUnusableMask) !== 0;
}
function data(element: ISyntaxElement): number {
// Debug.assert(isNode(element) || isList(element));
// Lists and nodes all have a 'data' element.
var dataElement = <ISyntaxNode>element;
var info = dataElement.__data;
if (info === undefined) {
info = 0;
}
if ((info & SyntaxNodeConstants.DataComputed) === 0) {
info += computeData(element);
dataElement.__data = info;
}
return info;
}
function combineData(fullWidth: number, isIncrementallyUnusable: boolean) {
return (fullWidth * SyntaxNodeConstants.FullWidthShift) +
(isIncrementallyUnusable ? SyntaxNodeConstants.IncrementallyUnusableMask : 0) +
SyntaxNodeConstants.DataComputed;
}
function listComputeData(list: ISyntaxNodeOrToken[]): number {
var fullWidth = 0;
var isIncrementallyUnusable = false;
for (var i = 0, n = list.length; i < n; i++) {
var child: ISyntaxElement = list[i];
fullWidth += TypeScript.fullWidth(child);
isIncrementallyUnusable = isIncrementallyUnusable || TypeScript.isIncrementallyUnusable(child);
}
return combineData(fullWidth, isIncrementallyUnusable);
}
function computeData(element: ISyntaxElement): number {
if (isList(element)) {
return listComputeData(<ISyntaxNodeOrToken[]>element);
}
else {
return nodeOrTokenComputeData(<ISyntaxNodeOrToken>element);
}
}
function nodeOrTokenComputeData(nodeOrToken: ISyntaxNodeOrToken) {
var fullWidth = 0;
var slotCount = nodeOrToken.childCount;
// If we have no children (like an OmmittedExpressionSyntax), we're automatically not reusable.
var isIncrementallyUnusable = slotCount === 0;
for (var i = 0, n = slotCount; i < n; i++) {
var child = nodeOrToken.childAt(i);
if (child) {
fullWidth += TypeScript.fullWidth(child);
isIncrementallyUnusable = isIncrementallyUnusable || TypeScript.isIncrementallyUnusable(child);
}
}
return combineData(fullWidth, isIncrementallyUnusable);
}
export function start(element: ISyntaxElement, text?: ISimpleText): number {
var token = isToken(element) ? <ISyntaxToken>element : firstToken(element);
return token ? token.fullStart() + token.leadingTriviaWidth(text) : -1;
}
export function width(element: ISyntaxElement, text?: ISimpleText): number {
if (isToken(element)) {
return (<ISyntaxToken>element).text().length;
}
return fullWidth(element) - leadingTriviaWidth(element, text);
}
export function fullEnd(element: ISyntaxElement): number {
return fullStart(element) + fullWidth(element);
}
export interface ISyntaxElement {
kind: SyntaxKind;
parent: ISyntaxElement;
}
export interface ISyntaxNode extends ISyntaxNodeOrToken {
__data: number;
}
export interface IModuleReferenceSyntax extends ISyntaxNode {
_moduleReferenceBrand: any;
}
export interface IModuleElementSyntax extends ISyntaxNode {
_moduleElementBrand: any;
}
export interface IStatementSyntax extends IModuleElementSyntax {
_statementBrand: any;
}
export interface ITypeMemberSyntax extends ISyntaxNode {
_typeMemberBrand: any;
}
export interface IClassElementSyntax extends ISyntaxNode {
_classElementBrand: any;
}
export interface IMemberDeclarationSyntax extends IClassElementSyntax {
_memberDeclarationBrand: any;
}
export interface IPropertyAssignmentSyntax extends ISyntaxNodeOrToken {
_propertyAssignmentBrand: any;
}
export interface IAccessorSyntax extends IPropertyAssignmentSyntax, IMemberDeclarationSyntax {
_accessorBrand: any;
modifiers: ISyntaxToken[];
propertyName: IPropertyNameSyntax;
callSignature: CallSignatureSyntax;
body: BlockSyntax | ExpressionBody | ISyntaxToken;
}
export interface ISwitchClauseSyntax extends ISyntaxNode {
_switchClauseBrand: any;
statements: IStatementSyntax[];
}
export interface IExpressionSyntax extends ISyntaxNodeOrToken {
_expressionBrand: any;
}
export interface IUnaryExpressionSyntax extends IExpressionSyntax {
_unaryExpressionBrand: any;
}
export interface IPostfixExpressionSyntax extends IUnaryExpressionSyntax {
_postfixExpressionBrand: any;
}
export interface ILeftHandSideExpressionSyntax extends IPostfixExpressionSyntax {
_leftHandSideExpressionBrand: any;
}
export interface IMemberExpressionSyntax extends ILeftHandSideExpressionSyntax {
_memberExpressionBrand: any;
}
export interface ICallExpressionSyntax extends ILeftHandSideExpressionSyntax {
_callExpressionBrand: any;
expression: IExpressionSyntax;
}
export interface IPrimaryExpressionSyntax extends IMemberExpressionSyntax {
_primaryExpressionBrand: any;
}
export interface ITypeSyntax extends ISyntaxNodeOrToken {
_typeBrand: any;
}
export interface INameSyntax extends ITypeSyntax {
_nameBrand: any;
}
export interface IPropertyNameSyntax extends ISyntaxNodeOrToken {
_propertyNameBrand: any;
}
}

View file

@ -1,250 +0,0 @@
///<reference path='syntaxKind.ts' />
module TypeScript.SyntaxFacts {
var textToKeywordKind: any = {
"any": SyntaxKind.AnyKeyword,
"async": SyntaxKind.AsyncKeyword,
"await": SyntaxKind.AwaitKeyword,
"boolean": SyntaxKind.BooleanKeyword,
"break": SyntaxKind.BreakKeyword,
"case": SyntaxKind.CaseKeyword,
"catch": SyntaxKind.CatchKeyword,
"class": SyntaxKind.ClassKeyword,
"continue": SyntaxKind.ContinueKeyword,
"const": SyntaxKind.ConstKeyword,
"constructor": SyntaxKind.ConstructorKeyword,
"debugger": SyntaxKind.DebuggerKeyword,
"declare": SyntaxKind.DeclareKeyword,
"default": SyntaxKind.DefaultKeyword,
"delete": SyntaxKind.DeleteKeyword,
"do": SyntaxKind.DoKeyword,
"else": SyntaxKind.ElseKeyword,
"enum": SyntaxKind.EnumKeyword,
"export": SyntaxKind.ExportKeyword,
"extends": SyntaxKind.ExtendsKeyword,
"false": SyntaxKind.FalseKeyword,
"finally": SyntaxKind.FinallyKeyword,
"for": SyntaxKind.ForKeyword,
"function": SyntaxKind.FunctionKeyword,
"get": SyntaxKind.GetKeyword,
"if": SyntaxKind.IfKeyword,
"implements": SyntaxKind.ImplementsKeyword,
"import": SyntaxKind.ImportKeyword,
"in": SyntaxKind.InKeyword,
"instanceof": SyntaxKind.InstanceOfKeyword,
"interface": SyntaxKind.InterfaceKeyword,
"let": SyntaxKind.LetKeyword,
"module": SyntaxKind.ModuleKeyword,
"new": SyntaxKind.NewKeyword,
"null": SyntaxKind.NullKeyword,
"number":SyntaxKind.NumberKeyword,
"package": SyntaxKind.PackageKeyword,
"private": SyntaxKind.PrivateKeyword,
"protected": SyntaxKind.ProtectedKeyword,
"public": SyntaxKind.PublicKeyword,
"require": SyntaxKind.RequireKeyword,
"return": SyntaxKind.ReturnKeyword,
"set": SyntaxKind.SetKeyword,
"static": SyntaxKind.StaticKeyword,
"string": SyntaxKind.StringKeyword,
"super": SyntaxKind.SuperKeyword,
"switch": SyntaxKind.SwitchKeyword,
"this": SyntaxKind.ThisKeyword,
"throw": SyntaxKind.ThrowKeyword,
"true": SyntaxKind.TrueKeyword,
"try": SyntaxKind.TryKeyword,
"type": SyntaxKind.TypeKeyword,
"typeof": SyntaxKind.TypeOfKeyword,
"var": SyntaxKind.VarKeyword,
"void": SyntaxKind.VoidKeyword,
"while": SyntaxKind.WhileKeyword,
"with": SyntaxKind.WithKeyword,
"yield": SyntaxKind.YieldKeyword,
"{": SyntaxKind.OpenBraceToken,
"}": SyntaxKind.CloseBraceToken,
"(": SyntaxKind.OpenParenToken,
")": SyntaxKind.CloseParenToken,
"[": SyntaxKind.OpenBracketToken,
"]": SyntaxKind.CloseBracketToken,
".": SyntaxKind.DotToken,
"...": SyntaxKind.DotDotDotToken,
";": SyntaxKind.SemicolonToken,
",": SyntaxKind.CommaToken,
"<": SyntaxKind.LessThanToken,
">": SyntaxKind.GreaterThanToken,
"<=": SyntaxKind.LessThanEqualsToken,
">=": SyntaxKind.GreaterThanEqualsToken,
"==": SyntaxKind.EqualsEqualsToken,
"=>": SyntaxKind.EqualsGreaterThanToken,
"!=": SyntaxKind.ExclamationEqualsToken,
"===": SyntaxKind.EqualsEqualsEqualsToken,
"!==": SyntaxKind.ExclamationEqualsEqualsToken,
"+": SyntaxKind.PlusToken,
"-": SyntaxKind.MinusToken,
"*": SyntaxKind.AsteriskToken,
"%": SyntaxKind.PercentToken,
"++": SyntaxKind.PlusPlusToken,
"--": SyntaxKind.MinusMinusToken,
"<<": SyntaxKind.LessThanLessThanToken,
">>": SyntaxKind.GreaterThanGreaterThanToken,
">>>": SyntaxKind.GreaterThanGreaterThanGreaterThanToken,
"&": SyntaxKind.AmpersandToken,
"|": SyntaxKind.BarToken,
"^": SyntaxKind.CaretToken,
"!": SyntaxKind.ExclamationToken,
"~": SyntaxKind.TildeToken,
"&&": SyntaxKind.AmpersandAmpersandToken,
"||": SyntaxKind.BarBarToken,
"?": SyntaxKind.QuestionToken,
":": SyntaxKind.ColonToken,
"=": SyntaxKind.EqualsToken,
"+=": SyntaxKind.PlusEqualsToken,
"-=": SyntaxKind.MinusEqualsToken,
"*=": SyntaxKind.AsteriskEqualsToken,
"%=": SyntaxKind.PercentEqualsToken,
"<<=": SyntaxKind.LessThanLessThanEqualsToken,
">>=": SyntaxKind.GreaterThanGreaterThanEqualsToken,
">>>=": SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken,
"&=": SyntaxKind.AmpersandEqualsToken,
"|=": SyntaxKind.BarEqualsToken,
"^=": SyntaxKind.CaretEqualsToken,
"/": SyntaxKind.SlashToken,
"/=": SyntaxKind.SlashEqualsToken,
};
var kindToText = new Array<string>();
for (var name in textToKeywordKind) {
if (textToKeywordKind.hasOwnProperty(name)) {
// Debug.assert(kindToText[textToKeywordKind[name]] === undefined);
kindToText[textToKeywordKind[name]] = name;
}
}
// Manually work around a bug in the CScript 5.8 runtime where 'constructor' is not
// listed when SyntaxFacts.textToKeywordKind is enumerated because it is the name of
// the constructor function.
kindToText[SyntaxKind.ConstructorKeyword] = "constructor";
export function getTokenKind(text: string): SyntaxKind {
if (textToKeywordKind.hasOwnProperty(text)) {
return textToKeywordKind[text];
}
return SyntaxKind.None;
}
export function getText(kind: SyntaxKind): string {
var result = kindToText[kind];
return result;// !== undefined ? result : undefined;
}
export function isAnyKeyword(kind: SyntaxKind): boolean {
return kind >= SyntaxKind.FirstKeyword && kind <= SyntaxKind.LastKeyword;
}
export function isAnyPunctuation(kind: SyntaxKind): boolean {
return kind >= SyntaxKind.FirstPunctuation && kind <= SyntaxKind.LastPunctuation;
}
export function isPrefixUnaryExpressionOperatorToken(tokenKind: SyntaxKind): boolean {
switch (tokenKind) {
case SyntaxKind.PlusToken:
case SyntaxKind.MinusToken:
case SyntaxKind.TildeToken:
case SyntaxKind.ExclamationToken:
case SyntaxKind.PlusPlusToken:
case SyntaxKind.MinusMinusToken:
return true;
default:
return false;
}
}
export function isBinaryExpressionOperatorToken(tokenKind: SyntaxKind): boolean {
switch (tokenKind) {
case SyntaxKind.AsteriskToken:
case SyntaxKind.SlashToken:
case SyntaxKind.PercentToken:
case SyntaxKind.PlusToken:
case SyntaxKind.MinusToken:
case SyntaxKind.LessThanLessThanToken:
case SyntaxKind.GreaterThanGreaterThanToken:
case SyntaxKind.GreaterThanGreaterThanGreaterThanToken:
case SyntaxKind.LessThanToken:
case SyntaxKind.GreaterThanToken:
case SyntaxKind.LessThanEqualsToken:
case SyntaxKind.GreaterThanEqualsToken:
case SyntaxKind.InstanceOfKeyword:
case SyntaxKind.InKeyword:
case SyntaxKind.EqualsEqualsToken:
case SyntaxKind.ExclamationEqualsToken:
case SyntaxKind.EqualsEqualsEqualsToken:
case SyntaxKind.ExclamationEqualsEqualsToken:
case SyntaxKind.AmpersandToken:
case SyntaxKind.CaretToken:
case SyntaxKind.BarToken:
case SyntaxKind.AmpersandAmpersandToken:
case SyntaxKind.BarBarToken:
case SyntaxKind.BarEqualsToken:
case SyntaxKind.AmpersandEqualsToken:
case SyntaxKind.CaretEqualsToken:
case SyntaxKind.LessThanLessThanEqualsToken:
case SyntaxKind.GreaterThanGreaterThanEqualsToken:
case SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken:
case SyntaxKind.PlusEqualsToken:
case SyntaxKind.MinusEqualsToken:
case SyntaxKind.AsteriskEqualsToken:
case SyntaxKind.SlashEqualsToken:
case SyntaxKind.PercentEqualsToken:
case SyntaxKind.EqualsToken:
case SyntaxKind.CommaToken:
return true;
default:
return false;
}
}
export function isAssignmentOperatorToken(tokenKind: SyntaxKind): boolean {
switch (tokenKind) {
case SyntaxKind.BarEqualsToken:
case SyntaxKind.AmpersandEqualsToken:
case SyntaxKind.CaretEqualsToken:
case SyntaxKind.LessThanLessThanEqualsToken:
case SyntaxKind.GreaterThanGreaterThanEqualsToken:
case SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken:
case SyntaxKind.PlusEqualsToken:
case SyntaxKind.MinusEqualsToken:
case SyntaxKind.AsteriskEqualsToken:
case SyntaxKind.SlashEqualsToken:
case SyntaxKind.PercentEqualsToken:
case SyntaxKind.EqualsToken:
return true;
default:
return false;
}
}
export function isType(kind: SyntaxKind): boolean {
switch (kind) {
case SyntaxKind.ArrayType:
case SyntaxKind.AnyKeyword:
case SyntaxKind.NumberKeyword:
case SyntaxKind.BooleanKeyword:
case SyntaxKind.StringKeyword:
case SyntaxKind.VoidKeyword:
case SyntaxKind.FunctionType:
case SyntaxKind.ObjectType:
case SyntaxKind.ConstructorType:
case SyntaxKind.TypeQuery:
case SyntaxKind.GenericType:
case SyntaxKind.QualifiedName:
case SyntaxKind.IdentifierName:
return true;
}
return false;
}
}

View file

@ -1,32 +0,0 @@
///<reference path='references.ts' />
module TypeScript.SyntaxFacts {
export function isDirectivePrologueElement(node: ISyntaxNodeOrToken): boolean {
return node.kind === SyntaxKind.ExpressionStatement &&
(<ExpressionStatementSyntax>node).expression.kind === SyntaxKind.StringLiteral;
}
export function isUseStrictDirective(node: ISyntaxNodeOrToken): boolean {
var expressionStatement = <ExpressionStatementSyntax>node;
var stringLiteral = <ISyntaxToken>expressionStatement.expression;
var text = stringLiteral.text();
return text === '"use strict"' || text === "'use strict'";
}
export function isIdentifierNameOrAnyKeyword(token: ISyntaxToken): boolean {
var tokenKind = token.kind;
return tokenKind === SyntaxKind.IdentifierName || SyntaxFacts.isAnyKeyword(tokenKind);
}
export function isAccessibilityModifier(kind: SyntaxKind): boolean {
switch (kind) {
case SyntaxKind.PublicKeyword:
case SyntaxKind.PrivateKeyword:
case SyntaxKind.ProtectedKeyword:
return true;
}
return false;
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,164 +0,0 @@
///<reference path='references.ts' />
module TypeScript {
export class SyntaxIndenter extends SyntaxRewriter {
private lastTriviaWasNewLine: boolean;
private indentationTrivia: ISyntaxTrivia;
constructor(indentFirstToken: boolean,
private indentationAmount: number,
private options: FormattingOptions) {
super();
this.lastTriviaWasNewLine = indentFirstToken;
this.indentationTrivia = Indentation.indentationTrivia(this.indentationAmount, this.options);
}
public visitToken(token: ISyntaxToken): ISyntaxToken {
if (token.width() === 0) {
return token;
}
var result = token;
if (this.lastTriviaWasNewLine) {
// have to add our indentation to every line that this token hits.
result = token.withLeadingTrivia(this.indentTriviaList(token.leadingTrivia()));
}
this.lastTriviaWasNewLine = token.hasTrailingNewLine();
return result;
}
public indentTriviaList(triviaList: ISyntaxTriviaList): ISyntaxTriviaList {
var result: ISyntaxTrivia[] = [];
// First, update any existing trivia with the indent amount. For example, combine the
// indent with any whitespace trivia, or prepend any comments with the trivia.
var indentNextTrivia = true;
for (var i = 0, n = triviaList.count(); i < n; i++) {
var trivia = triviaList.syntaxTriviaAt(i);
var indentThisTrivia = indentNextTrivia;
indentNextTrivia = false;
switch (trivia.kind()) {
case SyntaxKind.MultiLineCommentTrivia:
this.indentMultiLineComment(trivia, indentThisTrivia, result);
continue;
case SyntaxKind.SingleLineCommentTrivia:
case SyntaxKind.SkippedTokenTrivia:
this.indentSingleLineOrSkippedText(trivia, indentThisTrivia, result);
continue;
case SyntaxKind.WhitespaceTrivia:
this.indentWhitespace(trivia, indentThisTrivia, result);
continue;
case SyntaxKind.NewLineTrivia:
// We hit a newline processing the trivia. We need to add the indentation to the
// next line as well. Note: don't bother indenting the newline itself. This will
// just insert ugly whitespace that most users probably will not want.
result.push(trivia);
indentNextTrivia = true;
continue;
default:
throw Errors.invalidOperation();
}
}
// Then, if the last trivia was a newline (or there was no trivia at all), then just add the
// indentation in right before the token.
if (indentNextTrivia) {
result.push(this.indentationTrivia);
}
return Syntax.triviaList(result);
}
private indentSegment(segment: string): string {
// Find the position of the first non whitespace character in the segment.
var firstNonWhitespacePosition = Indentation.firstNonWhitespacePosition(segment);
if (firstNonWhitespacePosition < segment.length &&
CharacterInfo.isLineTerminator(segment.charCodeAt(firstNonWhitespacePosition))) {
// If this segment was just a newline, then don't bother indenting it. That will just
// leave the user with an ugly indent in their output that they probably do not want.
return segment;
}
// Convert that position to a column.
var firstNonWhitespaceColumn = Indentation.columnForPositionInString(segment, firstNonWhitespacePosition, this.options);
// Find the new column we want the nonwhitespace text to start at.
var newFirstNonWhitespaceColumn = firstNonWhitespaceColumn + this.indentationAmount;
// Compute an indentation string for that.
var indentationString = Indentation.indentationString(newFirstNonWhitespaceColumn, this.options);
// Join the new indentation and the original string without its indentation.
return indentationString + segment.substring(firstNonWhitespacePosition);
}
private indentWhitespace(trivia: ISyntaxTrivia, indentThisTrivia: boolean, result: ISyntaxTrivia[]): void {
if (!indentThisTrivia) {
// Line didn't start with this trivia. So no need to touch it. Just add to the result
// and continue on.
result.push(trivia);
return;
}
// Line started with this trivia. We want to figure out what the final column this
// whitespace goes to will be. To do that we add the column it is at now to the column we
// want to indent to. We then compute the final tabs+whitespace string for that.
var newIndentation = this.indentSegment(trivia.fullText());
result.push(Syntax.whitespace(newIndentation));
}
private indentSingleLineOrSkippedText(trivia: ISyntaxTrivia, indentThisTrivia: boolean, result: ISyntaxTrivia[]): void {
if (indentThisTrivia) {
// The line started with a comment or skipped text. Add an indentation based
// on the desired settings, and then add the trivia itself.
result.push(this.indentationTrivia);
}
result.push(trivia);
}
private indentMultiLineComment(trivia: ISyntaxTrivia, indentThisTrivia: boolean, result: ISyntaxTrivia[]): void {
if (indentThisTrivia) {
// The line started with a multiline comment. Add an indentation based
// on the desired settings, and then add the trivia itself.
result.push(this.indentationTrivia);
}
// If the multiline comment spans multiple lines, we need to add the right indent amount to
// each successive line segment as well.
var segments = Syntax.splitMultiLineCommentTriviaIntoMultipleLines(trivia);
for (var i = 1; i < segments.length; i++) {
segments[i] = this.indentSegment(segments[i]);
}
var newText = segments.join("");
result.push(Syntax.multiLineComment(newText));
}
public static indentNode(node: ISyntaxNode, indentFirstToken: boolean, indentAmount: number, options: FormattingOptions): SyntaxNode {
var indenter = new SyntaxIndenter(indentFirstToken, indentAmount, options);
return node.accept(indenter);
}
public static indentNodes(nodes: SyntaxNode[], indentFirstToken: boolean, indentAmount: number, options: FormattingOptions): SyntaxNode[] {
// Note: it is necessary for correctness that we reuse the same SyntaxIndenter here.
// That's because when working on nodes 1-N, we need to know if the previous node ended
// with a newline. The indenter will track that for us.
var indenter = new SyntaxIndenter(indentFirstToken, indentAmount, options);
var result: SyntaxNode[] = ArrayUtilities.select<any, any>(nodes, n => n.accept(indenter));
return result;
}
}
}

View file

@ -1,714 +0,0 @@
///<reference path='references.ts' />
module TypeScript {
export interface SourceUnitSyntax extends ISyntaxNode {
syntaxTree: SyntaxTree;
moduleElements: IModuleElementSyntax[];
endOfFileToken: ISyntaxToken;
}
export interface SourceUnitConstructor { new (data: number, moduleElements: IModuleElementSyntax[], endOfFileToken: ISyntaxToken): SourceUnitSyntax }
export interface QualifiedNameSyntax extends ISyntaxNode, INameSyntax {
left: INameSyntax;
dotToken: ISyntaxToken;
right: ISyntaxToken;
}
export interface QualifiedNameConstructor { new (data: number, left: INameSyntax, dotToken: ISyntaxToken, right: ISyntaxToken): QualifiedNameSyntax }
export interface ObjectTypeSyntax extends ISyntaxNode, ITypeSyntax {
openBraceToken: ISyntaxToken;
typeMembers: ITypeMemberSyntax[];
closeBraceToken: ISyntaxToken;
}
export interface ObjectTypeConstructor { new (data: number, openBraceToken: ISyntaxToken, typeMembers: ITypeMemberSyntax[], closeBraceToken: ISyntaxToken): ObjectTypeSyntax }
export interface FunctionTypeSyntax extends ISyntaxNode, ITypeSyntax {
typeParameterList: TypeParameterListSyntax;
parameterList: ParameterListSyntax;
equalsGreaterThanToken: ISyntaxToken;
type: ITypeSyntax;
}
export interface FunctionTypeConstructor { new (data: number, typeParameterList: TypeParameterListSyntax, parameterList: ParameterListSyntax, equalsGreaterThanToken: ISyntaxToken, type: ITypeSyntax): FunctionTypeSyntax }
export interface ArrayTypeSyntax extends ISyntaxNode, ITypeSyntax {
type: ITypeSyntax;
openBracketToken: ISyntaxToken;
closeBracketToken: ISyntaxToken;
}
export interface ArrayTypeConstructor { new (data: number, type: ITypeSyntax, openBracketToken: ISyntaxToken, closeBracketToken: ISyntaxToken): ArrayTypeSyntax }
export interface ConstructorTypeSyntax extends ISyntaxNode, ITypeSyntax {
newKeyword: ISyntaxToken;
typeParameterList: TypeParameterListSyntax;
parameterList: ParameterListSyntax;
equalsGreaterThanToken: ISyntaxToken;
type: ITypeSyntax;
}
export interface ConstructorTypeConstructor { new (data: number, newKeyword: ISyntaxToken, typeParameterList: TypeParameterListSyntax, parameterList: ParameterListSyntax, equalsGreaterThanToken: ISyntaxToken, type: ITypeSyntax): ConstructorTypeSyntax }
export interface GenericTypeSyntax extends ISyntaxNode, ITypeSyntax {
name: INameSyntax;
typeArgumentList: TypeArgumentListSyntax;
}
export interface GenericTypeConstructor { new (data: number, name: INameSyntax, typeArgumentList: TypeArgumentListSyntax): GenericTypeSyntax }
export interface TypeQuerySyntax extends ISyntaxNode, ITypeSyntax {
typeOfKeyword: ISyntaxToken;
name: INameSyntax;
}
export interface TypeQueryConstructor { new (data: number, typeOfKeyword: ISyntaxToken, name: INameSyntax): TypeQuerySyntax }
export interface TupleTypeSyntax extends ISyntaxNode, ITypeSyntax {
openBracketToken: ISyntaxToken;
types: ISeparatedSyntaxList<ITypeSyntax>;
closeBracketToken: ISyntaxToken;
}
export interface TupleTypeConstructor { new (data: number, openBracketToken: ISyntaxToken, types: ISeparatedSyntaxList<ITypeSyntax>, closeBracketToken: ISyntaxToken): TupleTypeSyntax }
export interface UnionTypeSyntax extends ISyntaxNode, ITypeSyntax {
left: ITypeSyntax;
barToken: ISyntaxToken;
right: ITypeSyntax;
}
export interface UnionTypeConstructor { new (data: number, left: ITypeSyntax, barToken: ISyntaxToken, right: ITypeSyntax): UnionTypeSyntax }
export interface ParenthesizedTypeSyntax extends ISyntaxNode, ITypeSyntax {
openParenToken: ISyntaxToken;
type: ITypeSyntax;
closeParenToken: ISyntaxToken;
}
export interface ParenthesizedTypeConstructor { new (data: number, openParenToken: ISyntaxToken, type: ITypeSyntax, closeParenToken: ISyntaxToken): ParenthesizedTypeSyntax }
export interface InterfaceDeclarationSyntax extends ISyntaxNode, IModuleElementSyntax {
modifiers: ISyntaxToken[];
interfaceKeyword: ISyntaxToken;
identifier: ISyntaxToken;
typeParameterList: TypeParameterListSyntax;
heritageClauses: HeritageClauseSyntax[];
body: ObjectTypeSyntax;
}
export interface InterfaceDeclarationConstructor { new (data: number, modifiers: ISyntaxToken[], interfaceKeyword: ISyntaxToken, identifier: ISyntaxToken, typeParameterList: TypeParameterListSyntax, heritageClauses: HeritageClauseSyntax[], body: ObjectTypeSyntax): InterfaceDeclarationSyntax }
export interface FunctionDeclarationSyntax extends ISyntaxNode, IStatementSyntax {
modifiers: ISyntaxToken[];
functionKeyword: ISyntaxToken;
asterixToken: ISyntaxToken;
identifier: ISyntaxToken;
callSignature: CallSignatureSyntax;
body: BlockSyntax | ExpressionBody | ISyntaxToken;
}
export interface FunctionDeclarationConstructor { new (data: number, modifiers: ISyntaxToken[], functionKeyword: ISyntaxToken, asterixToken: ISyntaxToken, identifier: ISyntaxToken, callSignature: CallSignatureSyntax, body: BlockSyntax | ExpressionBody | ISyntaxToken): FunctionDeclarationSyntax }
export interface ModuleDeclarationSyntax extends ISyntaxNode, IModuleElementSyntax {
modifiers: ISyntaxToken[];
moduleKeyword: ISyntaxToken;
name: INameSyntax;
openBraceToken: ISyntaxToken;
moduleElements: IModuleElementSyntax[];
closeBraceToken: ISyntaxToken;
}
export interface ModuleDeclarationConstructor { new (data: number, modifiers: ISyntaxToken[], moduleKeyword: ISyntaxToken, name: INameSyntax, openBraceToken: ISyntaxToken, moduleElements: IModuleElementSyntax[], closeBraceToken: ISyntaxToken): ModuleDeclarationSyntax }
export interface ClassDeclarationSyntax extends ISyntaxNode, IModuleElementSyntax {
modifiers: ISyntaxToken[];
classKeyword: ISyntaxToken;
identifier: ISyntaxToken;
typeParameterList: TypeParameterListSyntax;
heritageClauses: HeritageClauseSyntax[];
openBraceToken: ISyntaxToken;
classElements: IClassElementSyntax[];
closeBraceToken: ISyntaxToken;
}
export interface ClassDeclarationConstructor { new (data: number, modifiers: ISyntaxToken[], classKeyword: ISyntaxToken, identifier: ISyntaxToken, typeParameterList: TypeParameterListSyntax, heritageClauses: HeritageClauseSyntax[], openBraceToken: ISyntaxToken, classElements: IClassElementSyntax[], closeBraceToken: ISyntaxToken): ClassDeclarationSyntax }
export interface EnumDeclarationSyntax extends ISyntaxNode, IModuleElementSyntax {
modifiers: ISyntaxToken[];
enumKeyword: ISyntaxToken;
identifier: ISyntaxToken;
openBraceToken: ISyntaxToken;
enumElements: ISeparatedSyntaxList<EnumElementSyntax>;
closeBraceToken: ISyntaxToken;
}
export interface EnumDeclarationConstructor { new (data: number, modifiers: ISyntaxToken[], enumKeyword: ISyntaxToken, identifier: ISyntaxToken, openBraceToken: ISyntaxToken, enumElements: ISeparatedSyntaxList<EnumElementSyntax>, closeBraceToken: ISyntaxToken): EnumDeclarationSyntax }
export interface ImportDeclarationSyntax extends ISyntaxNode, IModuleElementSyntax {
modifiers: ISyntaxToken[];
importKeyword: ISyntaxToken;
identifier: ISyntaxToken;
equalsToken: ISyntaxToken;
moduleReference: IModuleReferenceSyntax;
semicolonToken: ISyntaxToken;
}
export interface ImportDeclarationConstructor { new (data: number, modifiers: ISyntaxToken[], importKeyword: ISyntaxToken, identifier: ISyntaxToken, equalsToken: ISyntaxToken, moduleReference: IModuleReferenceSyntax, semicolonToken: ISyntaxToken): ImportDeclarationSyntax }
export interface ExportAssignmentSyntax extends ISyntaxNode, IModuleElementSyntax {
modifiers: ISyntaxToken[];
exportKeyword: ISyntaxToken;
equalsToken: ISyntaxToken;
identifier: ISyntaxToken;
semicolonToken: ISyntaxToken;
}
export interface ExportAssignmentConstructor { new (data: number, modifiers: ISyntaxToken[], exportKeyword: ISyntaxToken, equalsToken: ISyntaxToken, identifier: ISyntaxToken, semicolonToken: ISyntaxToken): ExportAssignmentSyntax }
export interface MethodDeclarationSyntax extends ISyntaxNode, IMemberDeclarationSyntax, IPropertyAssignmentSyntax {
modifiers: ISyntaxToken[];
asterixToken: ISyntaxToken;
propertyName: IPropertyNameSyntax;
callSignature: CallSignatureSyntax;
body: BlockSyntax | ExpressionBody | ISyntaxToken;
}
export interface MethodDeclarationConstructor { new (data: number, modifiers: ISyntaxToken[], asterixToken: ISyntaxToken, propertyName: IPropertyNameSyntax, callSignature: CallSignatureSyntax, body: BlockSyntax | ExpressionBody | ISyntaxToken): MethodDeclarationSyntax }
export interface PropertyDeclarationSyntax extends ISyntaxNode, IMemberDeclarationSyntax {
modifiers: ISyntaxToken[];
variableDeclarator: VariableDeclaratorSyntax;
semicolonToken: ISyntaxToken;
}
export interface PropertyDeclarationConstructor { new (data: number, modifiers: ISyntaxToken[], variableDeclarator: VariableDeclaratorSyntax, semicolonToken: ISyntaxToken): PropertyDeclarationSyntax }
export interface ConstructorDeclarationSyntax extends ISyntaxNode, IClassElementSyntax {
modifiers: ISyntaxToken[];
constructorKeyword: ISyntaxToken;
callSignature: CallSignatureSyntax;
body: BlockSyntax | ExpressionBody | ISyntaxToken;
}
export interface ConstructorDeclarationConstructor { new (data: number, modifiers: ISyntaxToken[], constructorKeyword: ISyntaxToken, callSignature: CallSignatureSyntax, body: BlockSyntax | ExpressionBody | ISyntaxToken): ConstructorDeclarationSyntax }
export interface GetAccessorSyntax extends ISyntaxNode, IAccessorSyntax {
modifiers: ISyntaxToken[];
getKeyword: ISyntaxToken;
propertyName: IPropertyNameSyntax;
callSignature: CallSignatureSyntax;
body: BlockSyntax | ExpressionBody | ISyntaxToken;
}
export interface GetAccessorConstructor { new (data: number, modifiers: ISyntaxToken[], getKeyword: ISyntaxToken, propertyName: IPropertyNameSyntax, callSignature: CallSignatureSyntax, body: BlockSyntax | ExpressionBody | ISyntaxToken): GetAccessorSyntax }
export interface SetAccessorSyntax extends ISyntaxNode, IAccessorSyntax {
modifiers: ISyntaxToken[];
setKeyword: ISyntaxToken;
propertyName: IPropertyNameSyntax;
callSignature: CallSignatureSyntax;
body: BlockSyntax | ExpressionBody | ISyntaxToken;
}
export interface SetAccessorConstructor { new (data: number, modifiers: ISyntaxToken[], setKeyword: ISyntaxToken, propertyName: IPropertyNameSyntax, callSignature: CallSignatureSyntax, body: BlockSyntax | ExpressionBody | ISyntaxToken): SetAccessorSyntax }
export interface PropertySignatureSyntax extends ISyntaxNode, ITypeMemberSyntax {
propertyName: IPropertyNameSyntax;
questionToken: ISyntaxToken;
typeAnnotation: TypeAnnotationSyntax;
semicolonOrCommaToken: ISyntaxToken;
}
export interface PropertySignatureConstructor { new (data: number, propertyName: IPropertyNameSyntax, questionToken: ISyntaxToken, typeAnnotation: TypeAnnotationSyntax, semicolonOrCommaToken: ISyntaxToken): PropertySignatureSyntax }
export interface CallSignatureSyntax extends ISyntaxNode, ITypeMemberSyntax {
typeParameterList: TypeParameterListSyntax;
parameterList: ParameterListSyntax;
typeAnnotation: TypeAnnotationSyntax;
semicolonOrCommaToken: ISyntaxToken;
}
export interface CallSignatureConstructor { new (data: number, typeParameterList: TypeParameterListSyntax, parameterList: ParameterListSyntax, typeAnnotation: TypeAnnotationSyntax, semicolonOrCommaToken: ISyntaxToken): CallSignatureSyntax }
export interface ConstructSignatureSyntax extends ISyntaxNode, ITypeMemberSyntax {
newKeyword: ISyntaxToken;
callSignature: CallSignatureSyntax;
}
export interface ConstructSignatureConstructor { new (data: number, newKeyword: ISyntaxToken, callSignature: CallSignatureSyntax): ConstructSignatureSyntax }
export interface IndexSignatureSyntax extends ISyntaxNode, ITypeMemberSyntax, IClassElementSyntax {
modifiers: ISyntaxToken[];
openBracketToken: ISyntaxToken;
parameters: ISeparatedSyntaxList<ParameterSyntax>;
closeBracketToken: ISyntaxToken;
typeAnnotation: TypeAnnotationSyntax;
semicolonOrCommaToken: ISyntaxToken;
}
export interface IndexSignatureConstructor { new (data: number, modifiers: ISyntaxToken[], openBracketToken: ISyntaxToken, parameters: ISeparatedSyntaxList<ParameterSyntax>, closeBracketToken: ISyntaxToken, typeAnnotation: TypeAnnotationSyntax, semicolonOrCommaToken: ISyntaxToken): IndexSignatureSyntax }
export interface MethodSignatureSyntax extends ISyntaxNode, ITypeMemberSyntax {
propertyName: IPropertyNameSyntax;
questionToken: ISyntaxToken;
callSignature: CallSignatureSyntax;
}
export interface MethodSignatureConstructor { new (data: number, propertyName: IPropertyNameSyntax, questionToken: ISyntaxToken, callSignature: CallSignatureSyntax): MethodSignatureSyntax }
export interface BlockSyntax extends ISyntaxNode, IStatementSyntax {
equalsGreaterThanToken: ISyntaxToken;
openBraceToken: ISyntaxToken;
statements: IStatementSyntax[];
closeBraceToken: ISyntaxToken;
}
export interface BlockConstructor { new (data: number, equalsGreaterThanToken: ISyntaxToken, openBraceToken: ISyntaxToken, statements: IStatementSyntax[], closeBraceToken: ISyntaxToken): BlockSyntax }
export interface IfStatementSyntax extends ISyntaxNode, IStatementSyntax {
ifKeyword: ISyntaxToken;
openParenToken: ISyntaxToken;
condition: IExpressionSyntax;
closeParenToken: ISyntaxToken;
statement: IStatementSyntax;
elseClause: ElseClauseSyntax;
}
export interface IfStatementConstructor { new (data: number, ifKeyword: ISyntaxToken, openParenToken: ISyntaxToken, condition: IExpressionSyntax, closeParenToken: ISyntaxToken, statement: IStatementSyntax, elseClause: ElseClauseSyntax): IfStatementSyntax }
export interface VariableStatementSyntax extends ISyntaxNode, IStatementSyntax {
modifiers: ISyntaxToken[];
variableDeclaration: VariableDeclarationSyntax;
semicolonToken: ISyntaxToken;
}
export interface VariableStatementConstructor { new (data: number, modifiers: ISyntaxToken[], variableDeclaration: VariableDeclarationSyntax, semicolonToken: ISyntaxToken): VariableStatementSyntax }
export interface ExpressionStatementSyntax extends ISyntaxNode, IStatementSyntax {
expression: IExpressionSyntax;
semicolonToken: ISyntaxToken;
}
export interface ExpressionStatementConstructor { new (data: number, expression: IExpressionSyntax, semicolonToken: ISyntaxToken): ExpressionStatementSyntax }
export interface ReturnStatementSyntax extends ISyntaxNode, IStatementSyntax {
returnKeyword: ISyntaxToken;
expression: IExpressionSyntax;
semicolonToken: ISyntaxToken;
}
export interface ReturnStatementConstructor { new (data: number, returnKeyword: ISyntaxToken, expression: IExpressionSyntax, semicolonToken: ISyntaxToken): ReturnStatementSyntax }
export interface SwitchStatementSyntax extends ISyntaxNode, IStatementSyntax {
switchKeyword: ISyntaxToken;
openParenToken: ISyntaxToken;
expression: IExpressionSyntax;
closeParenToken: ISyntaxToken;
openBraceToken: ISyntaxToken;
switchClauses: ISwitchClauseSyntax[];
closeBraceToken: ISyntaxToken;
}
export interface SwitchStatementConstructor { new (data: number, switchKeyword: ISyntaxToken, openParenToken: ISyntaxToken, expression: IExpressionSyntax, closeParenToken: ISyntaxToken, openBraceToken: ISyntaxToken, switchClauses: ISwitchClauseSyntax[], closeBraceToken: ISyntaxToken): SwitchStatementSyntax }
export interface BreakStatementSyntax extends ISyntaxNode, IStatementSyntax {
breakKeyword: ISyntaxToken;
identifier: ISyntaxToken;
semicolonToken: ISyntaxToken;
}
export interface BreakStatementConstructor { new (data: number, breakKeyword: ISyntaxToken, identifier: ISyntaxToken, semicolonToken: ISyntaxToken): BreakStatementSyntax }
export interface ContinueStatementSyntax extends ISyntaxNode, IStatementSyntax {
continueKeyword: ISyntaxToken;
identifier: ISyntaxToken;
semicolonToken: ISyntaxToken;
}
export interface ContinueStatementConstructor { new (data: number, continueKeyword: ISyntaxToken, identifier: ISyntaxToken, semicolonToken: ISyntaxToken): ContinueStatementSyntax }
export interface ForStatementSyntax extends ISyntaxNode, IStatementSyntax {
forKeyword: ISyntaxToken;
openParenToken: ISyntaxToken;
initializer: VariableDeclarationSyntax | IExpressionSyntax;
firstSemicolonToken: ISyntaxToken;
condition: IExpressionSyntax;
secondSemicolonToken: ISyntaxToken;
incrementor: IExpressionSyntax;
closeParenToken: ISyntaxToken;
statement: IStatementSyntax;
}
export interface ForStatementConstructor { new (data: number, forKeyword: ISyntaxToken, openParenToken: ISyntaxToken, initializer: VariableDeclarationSyntax | IExpressionSyntax, firstSemicolonToken: ISyntaxToken, condition: IExpressionSyntax, secondSemicolonToken: ISyntaxToken, incrementor: IExpressionSyntax, closeParenToken: ISyntaxToken, statement: IStatementSyntax): ForStatementSyntax }
export interface ForInStatementSyntax extends ISyntaxNode, IStatementSyntax {
forKeyword: ISyntaxToken;
openParenToken: ISyntaxToken;
left: VariableDeclarationSyntax | IExpressionSyntax;
inKeyword: ISyntaxToken;
right: IExpressionSyntax;
closeParenToken: ISyntaxToken;
statement: IStatementSyntax;
}
export interface ForInStatementConstructor { new (data: number, forKeyword: ISyntaxToken, openParenToken: ISyntaxToken, left: VariableDeclarationSyntax | IExpressionSyntax, inKeyword: ISyntaxToken, right: IExpressionSyntax, closeParenToken: ISyntaxToken, statement: IStatementSyntax): ForInStatementSyntax }
export interface EmptyStatementSyntax extends ISyntaxNode, IStatementSyntax {
semicolonToken: ISyntaxToken;
}
export interface EmptyStatementConstructor { new (data: number, semicolonToken: ISyntaxToken): EmptyStatementSyntax }
export interface ThrowStatementSyntax extends ISyntaxNode, IStatementSyntax {
throwKeyword: ISyntaxToken;
expression: IExpressionSyntax;
semicolonToken: ISyntaxToken;
}
export interface ThrowStatementConstructor { new (data: number, throwKeyword: ISyntaxToken, expression: IExpressionSyntax, semicolonToken: ISyntaxToken): ThrowStatementSyntax }
export interface WhileStatementSyntax extends ISyntaxNode, IStatementSyntax {
whileKeyword: ISyntaxToken;
openParenToken: ISyntaxToken;
condition: IExpressionSyntax;
closeParenToken: ISyntaxToken;
statement: IStatementSyntax;
}
export interface WhileStatementConstructor { new (data: number, whileKeyword: ISyntaxToken, openParenToken: ISyntaxToken, condition: IExpressionSyntax, closeParenToken: ISyntaxToken, statement: IStatementSyntax): WhileStatementSyntax }
export interface TryStatementSyntax extends ISyntaxNode, IStatementSyntax {
tryKeyword: ISyntaxToken;
block: BlockSyntax;
catchClause: CatchClauseSyntax;
finallyClause: FinallyClauseSyntax;
}
export interface TryStatementConstructor { new (data: number, tryKeyword: ISyntaxToken, block: BlockSyntax, catchClause: CatchClauseSyntax, finallyClause: FinallyClauseSyntax): TryStatementSyntax }
export interface LabeledStatementSyntax extends ISyntaxNode, IStatementSyntax {
identifier: ISyntaxToken;
colonToken: ISyntaxToken;
statement: IStatementSyntax;
}
export interface LabeledStatementConstructor { new (data: number, identifier: ISyntaxToken, colonToken: ISyntaxToken, statement: IStatementSyntax): LabeledStatementSyntax }
export interface DoStatementSyntax extends ISyntaxNode, IStatementSyntax {
doKeyword: ISyntaxToken;
statement: IStatementSyntax;
whileKeyword: ISyntaxToken;
openParenToken: ISyntaxToken;
condition: IExpressionSyntax;
closeParenToken: ISyntaxToken;
semicolonToken: ISyntaxToken;
}
export interface DoStatementConstructor { new (data: number, doKeyword: ISyntaxToken, statement: IStatementSyntax, whileKeyword: ISyntaxToken, openParenToken: ISyntaxToken, condition: IExpressionSyntax, closeParenToken: ISyntaxToken, semicolonToken: ISyntaxToken): DoStatementSyntax }
export interface DebuggerStatementSyntax extends ISyntaxNode, IStatementSyntax {
debuggerKeyword: ISyntaxToken;
semicolonToken: ISyntaxToken;
}
export interface DebuggerStatementConstructor { new (data: number, debuggerKeyword: ISyntaxToken, semicolonToken: ISyntaxToken): DebuggerStatementSyntax }
export interface WithStatementSyntax extends ISyntaxNode, IStatementSyntax {
withKeyword: ISyntaxToken;
openParenToken: ISyntaxToken;
condition: IExpressionSyntax;
closeParenToken: ISyntaxToken;
statement: IStatementSyntax;
}
export interface WithStatementConstructor { new (data: number, withKeyword: ISyntaxToken, openParenToken: ISyntaxToken, condition: IExpressionSyntax, closeParenToken: ISyntaxToken, statement: IStatementSyntax): WithStatementSyntax }
export interface PrefixUnaryExpressionSyntax extends ISyntaxNode, IUnaryExpressionSyntax {
operatorToken: ISyntaxToken;
operand: IUnaryExpressionSyntax;
}
export interface PrefixUnaryExpressionConstructor { new (data: number, operatorToken: ISyntaxToken, operand: IUnaryExpressionSyntax): PrefixUnaryExpressionSyntax }
export interface DeleteExpressionSyntax extends ISyntaxNode, IUnaryExpressionSyntax {
deleteKeyword: ISyntaxToken;
expression: IUnaryExpressionSyntax;
}
export interface DeleteExpressionConstructor { new (data: number, deleteKeyword: ISyntaxToken, expression: IUnaryExpressionSyntax): DeleteExpressionSyntax }
export interface TypeOfExpressionSyntax extends ISyntaxNode, IUnaryExpressionSyntax {
typeOfKeyword: ISyntaxToken;
expression: IUnaryExpressionSyntax;
}
export interface TypeOfExpressionConstructor { new (data: number, typeOfKeyword: ISyntaxToken, expression: IUnaryExpressionSyntax): TypeOfExpressionSyntax }
export interface VoidExpressionSyntax extends ISyntaxNode, IUnaryExpressionSyntax {
voidKeyword: ISyntaxToken;
expression: IUnaryExpressionSyntax;
}
export interface VoidExpressionConstructor { new (data: number, voidKeyword: ISyntaxToken, expression: IUnaryExpressionSyntax): VoidExpressionSyntax }
export interface ConditionalExpressionSyntax extends ISyntaxNode, IExpressionSyntax {
condition: IExpressionSyntax;
questionToken: ISyntaxToken;
whenTrue: IExpressionSyntax;
colonToken: ISyntaxToken;
whenFalse: IExpressionSyntax;
}
export interface ConditionalExpressionConstructor { new (data: number, condition: IExpressionSyntax, questionToken: ISyntaxToken, whenTrue: IExpressionSyntax, colonToken: ISyntaxToken, whenFalse: IExpressionSyntax): ConditionalExpressionSyntax }
export interface BinaryExpressionSyntax extends ISyntaxNode, IExpressionSyntax {
left: IExpressionSyntax;
operatorToken: ISyntaxToken;
right: IExpressionSyntax;
}
export interface BinaryExpressionConstructor { new (data: number, left: IExpressionSyntax, operatorToken: ISyntaxToken, right: IExpressionSyntax): BinaryExpressionSyntax }
export interface PostfixUnaryExpressionSyntax extends ISyntaxNode, IPostfixExpressionSyntax {
operand: ILeftHandSideExpressionSyntax;
operatorToken: ISyntaxToken;
}
export interface PostfixUnaryExpressionConstructor { new (data: number, operand: ILeftHandSideExpressionSyntax, operatorToken: ISyntaxToken): PostfixUnaryExpressionSyntax }
export interface PropertyAccessExpressionSyntax extends ISyntaxNode, IMemberExpressionSyntax, ICallExpressionSyntax {
expression: ILeftHandSideExpressionSyntax;
dotToken: ISyntaxToken;
name: ISyntaxToken;
}
export interface PropertyAccessExpressionConstructor { new (data: number, expression: ILeftHandSideExpressionSyntax, dotToken: ISyntaxToken, name: ISyntaxToken): PropertyAccessExpressionSyntax }
export interface InvocationExpressionSyntax extends ISyntaxNode, ICallExpressionSyntax {
expression: ILeftHandSideExpressionSyntax;
argumentList: ArgumentListSyntax;
}
export interface InvocationExpressionConstructor { new (data: number, expression: ILeftHandSideExpressionSyntax, argumentList: ArgumentListSyntax): InvocationExpressionSyntax }
export interface ArrayLiteralExpressionSyntax extends ISyntaxNode, IPrimaryExpressionSyntax {
openBracketToken: ISyntaxToken;
expressions: ISeparatedSyntaxList<IExpressionSyntax>;
closeBracketToken: ISyntaxToken;
}
export interface ArrayLiteralExpressionConstructor { new (data: number, openBracketToken: ISyntaxToken, expressions: ISeparatedSyntaxList<IExpressionSyntax>, closeBracketToken: ISyntaxToken): ArrayLiteralExpressionSyntax }
export interface ObjectLiteralExpressionSyntax extends ISyntaxNode, IPrimaryExpressionSyntax {
openBraceToken: ISyntaxToken;
propertyAssignments: ISeparatedSyntaxList<IPropertyAssignmentSyntax>;
closeBraceToken: ISyntaxToken;
}
export interface ObjectLiteralExpressionConstructor { new (data: number, openBraceToken: ISyntaxToken, propertyAssignments: ISeparatedSyntaxList<IPropertyAssignmentSyntax>, closeBraceToken: ISyntaxToken): ObjectLiteralExpressionSyntax }
export interface ObjectCreationExpressionSyntax extends ISyntaxNode, IPrimaryExpressionSyntax {
newKeyword: ISyntaxToken;
expression: IMemberExpressionSyntax;
argumentList: ArgumentListSyntax;
}
export interface ObjectCreationExpressionConstructor { new (data: number, newKeyword: ISyntaxToken, expression: IMemberExpressionSyntax, argumentList: ArgumentListSyntax): ObjectCreationExpressionSyntax }
export interface ParenthesizedExpressionSyntax extends ISyntaxNode, IPrimaryExpressionSyntax {
openParenToken: ISyntaxToken;
expression: IExpressionSyntax;
closeParenToken: ISyntaxToken;
}
export interface ParenthesizedExpressionConstructor { new (data: number, openParenToken: ISyntaxToken, expression: IExpressionSyntax, closeParenToken: ISyntaxToken): ParenthesizedExpressionSyntax }
export interface ParenthesizedArrowFunctionExpressionSyntax extends ISyntaxNode, IUnaryExpressionSyntax {
asyncKeyword: ISyntaxToken;
callSignature: CallSignatureSyntax;
equalsGreaterThanToken: ISyntaxToken;
body: BlockSyntax | IExpressionSyntax;
}
export interface ParenthesizedArrowFunctionExpressionConstructor { new (data: number, asyncKeyword: ISyntaxToken, callSignature: CallSignatureSyntax, equalsGreaterThanToken: ISyntaxToken, body: BlockSyntax | IExpressionSyntax): ParenthesizedArrowFunctionExpressionSyntax }
export interface SimpleArrowFunctionExpressionSyntax extends ISyntaxNode, IUnaryExpressionSyntax {
asyncKeyword: ISyntaxToken;
parameter: ParameterSyntax;
equalsGreaterThanToken: ISyntaxToken;
body: BlockSyntax | IExpressionSyntax;
}
export interface SimpleArrowFunctionExpressionConstructor { new (data: number, asyncKeyword: ISyntaxToken, parameter: ParameterSyntax, equalsGreaterThanToken: ISyntaxToken, body: BlockSyntax | IExpressionSyntax): SimpleArrowFunctionExpressionSyntax }
export interface TypeAssertionExpressionSyntax extends ISyntaxNode, IUnaryExpressionSyntax {
lessThanToken: ISyntaxToken;
type: ITypeSyntax;
greaterThanToken: ISyntaxToken;
expression: IUnaryExpressionSyntax;
}
export interface TypeAssertionExpressionConstructor { new (data: number, lessThanToken: ISyntaxToken, type: ITypeSyntax, greaterThanToken: ISyntaxToken, expression: IUnaryExpressionSyntax): TypeAssertionExpressionSyntax }
export interface ElementAccessExpressionSyntax extends ISyntaxNode, IMemberExpressionSyntax, ICallExpressionSyntax {
expression: ILeftHandSideExpressionSyntax;
openBracketToken: ISyntaxToken;
argumentExpression: IExpressionSyntax;
closeBracketToken: ISyntaxToken;
}
export interface ElementAccessExpressionConstructor { new (data: number, expression: ILeftHandSideExpressionSyntax, openBracketToken: ISyntaxToken, argumentExpression: IExpressionSyntax, closeBracketToken: ISyntaxToken): ElementAccessExpressionSyntax }
export interface FunctionExpressionSyntax extends ISyntaxNode, IPrimaryExpressionSyntax {
asyncKeyword: ISyntaxToken;
functionKeyword: ISyntaxToken;
asterixToken: ISyntaxToken;
identifier: ISyntaxToken;
callSignature: CallSignatureSyntax;
body: BlockSyntax | ExpressionBody | ISyntaxToken;
}
export interface FunctionExpressionConstructor { new (data: number, asyncKeyword: ISyntaxToken, functionKeyword: ISyntaxToken, asterixToken: ISyntaxToken, identifier: ISyntaxToken, callSignature: CallSignatureSyntax, body: BlockSyntax | ExpressionBody | ISyntaxToken): FunctionExpressionSyntax }
export interface OmittedExpressionSyntax extends ISyntaxNode, IExpressionSyntax {
}
export interface OmittedExpressionConstructor { new (data: number): OmittedExpressionSyntax }
export interface TemplateExpressionSyntax extends ISyntaxNode, IPrimaryExpressionSyntax {
templateStartToken: ISyntaxToken;
templateClauses: TemplateClauseSyntax[];
}
export interface TemplateExpressionConstructor { new (data: number, templateStartToken: ISyntaxToken, templateClauses: TemplateClauseSyntax[]): TemplateExpressionSyntax }
export interface TemplateAccessExpressionSyntax extends ISyntaxNode, IMemberExpressionSyntax, ICallExpressionSyntax {
expression: ILeftHandSideExpressionSyntax;
templateExpression: IPrimaryExpressionSyntax;
}
export interface TemplateAccessExpressionConstructor { new (data: number, expression: ILeftHandSideExpressionSyntax, templateExpression: IPrimaryExpressionSyntax): TemplateAccessExpressionSyntax }
export interface YieldExpressionSyntax extends ISyntaxNode, IExpressionSyntax {
yieldKeyword: ISyntaxToken;
asterixToken: ISyntaxToken;
expression: IExpressionSyntax;
}
export interface YieldExpressionConstructor { new (data: number, yieldKeyword: ISyntaxToken, asterixToken: ISyntaxToken, expression: IExpressionSyntax): YieldExpressionSyntax }
export interface AwaitExpressionSyntax extends ISyntaxNode, IUnaryExpressionSyntax {
awaitKeyword: ISyntaxToken;
expression: IUnaryExpressionSyntax;
}
export interface AwaitExpressionConstructor { new (data: number, awaitKeyword: ISyntaxToken, expression: IUnaryExpressionSyntax): AwaitExpressionSyntax }
export interface VariableDeclarationSyntax extends ISyntaxNode {
varConstOrLetKeyword: ISyntaxToken;
variableDeclarators: ISeparatedSyntaxList<VariableDeclaratorSyntax>;
}
export interface VariableDeclarationConstructor { new (data: number, varConstOrLetKeyword: ISyntaxToken, variableDeclarators: ISeparatedSyntaxList<VariableDeclaratorSyntax>): VariableDeclarationSyntax }
export interface VariableDeclaratorSyntax extends ISyntaxNode {
propertyName: IPropertyNameSyntax;
typeAnnotation: TypeAnnotationSyntax;
equalsValueClause: EqualsValueClauseSyntax;
}
export interface VariableDeclaratorConstructor { new (data: number, propertyName: IPropertyNameSyntax, typeAnnotation: TypeAnnotationSyntax, equalsValueClause: EqualsValueClauseSyntax): VariableDeclaratorSyntax }
export interface ArgumentListSyntax extends ISyntaxNode {
typeArgumentList: TypeArgumentListSyntax;
openParenToken: ISyntaxToken;
arguments: ISeparatedSyntaxList<IExpressionSyntax>;
closeParenToken: ISyntaxToken;
}
export interface ArgumentListConstructor { new (data: number, typeArgumentList: TypeArgumentListSyntax, openParenToken: ISyntaxToken, _arguments: ISeparatedSyntaxList<IExpressionSyntax>, closeParenToken: ISyntaxToken): ArgumentListSyntax }
export interface ParameterListSyntax extends ISyntaxNode {
openParenToken: ISyntaxToken;
parameters: ISeparatedSyntaxList<ParameterSyntax>;
closeParenToken: ISyntaxToken;
}
export interface ParameterListConstructor { new (data: number, openParenToken: ISyntaxToken, parameters: ISeparatedSyntaxList<ParameterSyntax>, closeParenToken: ISyntaxToken): ParameterListSyntax }
export interface TypeArgumentListSyntax extends ISyntaxNode {
lessThanToken: ISyntaxToken;
typeArguments: ISeparatedSyntaxList<ITypeSyntax>;
greaterThanToken: ISyntaxToken;
}
export interface TypeArgumentListConstructor { new (data: number, lessThanToken: ISyntaxToken, typeArguments: ISeparatedSyntaxList<ITypeSyntax>, greaterThanToken: ISyntaxToken): TypeArgumentListSyntax }
export interface TypeParameterListSyntax extends ISyntaxNode {
lessThanToken: ISyntaxToken;
typeParameters: ISeparatedSyntaxList<TypeParameterSyntax>;
greaterThanToken: ISyntaxToken;
}
export interface TypeParameterListConstructor { new (data: number, lessThanToken: ISyntaxToken, typeParameters: ISeparatedSyntaxList<TypeParameterSyntax>, greaterThanToken: ISyntaxToken): TypeParameterListSyntax }
export interface HeritageClauseSyntax extends ISyntaxNode {
extendsOrImplementsKeyword: ISyntaxToken;
typeNames: ISeparatedSyntaxList<INameSyntax>;
}
export interface HeritageClauseConstructor { new (data: number, extendsOrImplementsKeyword: ISyntaxToken, typeNames: ISeparatedSyntaxList<INameSyntax>): HeritageClauseSyntax }
export interface EqualsValueClauseSyntax extends ISyntaxNode {
equalsToken: ISyntaxToken;
value: IExpressionSyntax;
}
export interface EqualsValueClauseConstructor { new (data: number, equalsToken: ISyntaxToken, value: IExpressionSyntax): EqualsValueClauseSyntax }
export interface CaseSwitchClauseSyntax extends ISyntaxNode, ISwitchClauseSyntax {
caseKeyword: ISyntaxToken;
expression: IExpressionSyntax;
colonToken: ISyntaxToken;
statements: IStatementSyntax[];
}
export interface CaseSwitchClauseConstructor { new (data: number, caseKeyword: ISyntaxToken, expression: IExpressionSyntax, colonToken: ISyntaxToken, statements: IStatementSyntax[]): CaseSwitchClauseSyntax }
export interface DefaultSwitchClauseSyntax extends ISyntaxNode, ISwitchClauseSyntax {
defaultKeyword: ISyntaxToken;
colonToken: ISyntaxToken;
statements: IStatementSyntax[];
}
export interface DefaultSwitchClauseConstructor { new (data: number, defaultKeyword: ISyntaxToken, colonToken: ISyntaxToken, statements: IStatementSyntax[]): DefaultSwitchClauseSyntax }
export interface ElseClauseSyntax extends ISyntaxNode {
elseKeyword: ISyntaxToken;
statement: IStatementSyntax;
}
export interface ElseClauseConstructor { new (data: number, elseKeyword: ISyntaxToken, statement: IStatementSyntax): ElseClauseSyntax }
export interface CatchClauseSyntax extends ISyntaxNode {
catchKeyword: ISyntaxToken;
openParenToken: ISyntaxToken;
identifier: ISyntaxToken;
typeAnnotation: TypeAnnotationSyntax;
closeParenToken: ISyntaxToken;
block: BlockSyntax;
}
export interface CatchClauseConstructor { new (data: number, catchKeyword: ISyntaxToken, openParenToken: ISyntaxToken, identifier: ISyntaxToken, typeAnnotation: TypeAnnotationSyntax, closeParenToken: ISyntaxToken, block: BlockSyntax): CatchClauseSyntax }
export interface FinallyClauseSyntax extends ISyntaxNode {
finallyKeyword: ISyntaxToken;
block: BlockSyntax;
}
export interface FinallyClauseConstructor { new (data: number, finallyKeyword: ISyntaxToken, block: BlockSyntax): FinallyClauseSyntax }
export interface TemplateClauseSyntax extends ISyntaxNode {
expression: IExpressionSyntax;
templateMiddleOrEndToken: ISyntaxToken;
}
export interface TemplateClauseConstructor { new (data: number, expression: IExpressionSyntax, templateMiddleOrEndToken: ISyntaxToken): TemplateClauseSyntax }
export interface TypeParameterSyntax extends ISyntaxNode {
identifier: ISyntaxToken;
constraint: ConstraintSyntax;
}
export interface TypeParameterConstructor { new (data: number, identifier: ISyntaxToken, constraint: ConstraintSyntax): TypeParameterSyntax }
export interface ConstraintSyntax extends ISyntaxNode {
extendsKeyword: ISyntaxToken;
typeOrExpression: ISyntaxNodeOrToken;
}
export interface ConstraintConstructor { new (data: number, extendsKeyword: ISyntaxToken, typeOrExpression: ISyntaxNodeOrToken): ConstraintSyntax }
export interface ParameterSyntax extends ISyntaxNode {
dotDotDotToken: ISyntaxToken;
modifiers: ISyntaxToken[];
identifier: ISyntaxToken;
questionToken: ISyntaxToken;
typeAnnotation: TypeAnnotationSyntax;
equalsValueClause: EqualsValueClauseSyntax;
}
export interface ParameterConstructor { new (data: number, dotDotDotToken: ISyntaxToken, modifiers: ISyntaxToken[], identifier: ISyntaxToken, questionToken: ISyntaxToken, typeAnnotation: TypeAnnotationSyntax, equalsValueClause: EqualsValueClauseSyntax): ParameterSyntax }
export interface EnumElementSyntax extends ISyntaxNode {
propertyName: IPropertyNameSyntax;
equalsValueClause: EqualsValueClauseSyntax;
}
export interface EnumElementConstructor { new (data: number, propertyName: IPropertyNameSyntax, equalsValueClause: EqualsValueClauseSyntax): EnumElementSyntax }
export interface TypeAnnotationSyntax extends ISyntaxNode {
colonToken: ISyntaxToken;
type: ITypeSyntax;
}
export interface TypeAnnotationConstructor { new (data: number, colonToken: ISyntaxToken, type: ITypeSyntax): TypeAnnotationSyntax }
export interface ExpressionBody extends ISyntaxNode {
equalsGreaterThanToken: ISyntaxToken;
expression: IExpressionSyntax;
}
export interface ExpressionBodyConstructor { new (data: number, equalsGreaterThanToken: ISyntaxToken, expression: IExpressionSyntax): ExpressionBody }
export interface ComputedPropertyNameSyntax extends ISyntaxNode, IPropertyNameSyntax {
openBracketToken: ISyntaxToken;
expression: IExpressionSyntax;
closeBracketToken: ISyntaxToken;
}
export interface ComputedPropertyNameConstructor { new (data: number, openBracketToken: ISyntaxToken, expression: IExpressionSyntax, closeBracketToken: ISyntaxToken): ComputedPropertyNameSyntax }
export interface PropertyAssignmentSyntax extends ISyntaxNode, IPropertyAssignmentSyntax {
propertyName: IPropertyNameSyntax;
colonToken: ISyntaxToken;
expression: IExpressionSyntax;
}
export interface PropertyAssignmentConstructor { new (data: number, propertyName: IPropertyNameSyntax, colonToken: ISyntaxToken, expression: IExpressionSyntax): PropertyAssignmentSyntax }
export interface TypeAliasSyntax extends ISyntaxNode, IModuleElementSyntax {
modifiers: ISyntaxToken[];
typeKeyword: ISyntaxToken;
identifier: ISyntaxToken;
equalsToken: ISyntaxToken;
type: ITypeSyntax;
semicolonToken: ISyntaxToken;
}
export interface TypeAliasConstructor { new (data: number, modifiers: ISyntaxToken[], typeKeyword: ISyntaxToken, identifier: ISyntaxToken, equalsToken: ISyntaxToken, type: ITypeSyntax, semicolonToken: ISyntaxToken): TypeAliasSyntax }
export interface ExternalModuleReferenceSyntax extends ISyntaxNode, IModuleReferenceSyntax {
requireKeyword: ISyntaxToken;
openParenToken: ISyntaxToken;
expression: IExpressionSyntax;
closeParenToken: ISyntaxToken;
}
export interface ExternalModuleReferenceConstructor { new (data: number, requireKeyword: ISyntaxToken, openParenToken: ISyntaxToken, expression: IExpressionSyntax, closeParenToken: ISyntaxToken): ExternalModuleReferenceSyntax }
export interface ModuleNameModuleReferenceSyntax extends ISyntaxNode, IModuleReferenceSyntax {
moduleName: INameSyntax;
}
export interface ModuleNameModuleReferenceConstructor { new (data: number, moduleName: INameSyntax): ModuleNameModuleReferenceSyntax }
}

View file

@ -1,307 +0,0 @@
// If you change anything in this enum, make sure you run SyntaxGenerator again!
module TypeScript {
export const enum SyntaxKind {
// Variable width tokens, trivia and lists.
None,
List,
// Trivia
WhitespaceTrivia,
NewLineTrivia,
MultiLineCommentTrivia,
SingleLineCommentTrivia,
SkippedTokenTrivia,
// Note: all variable width tokens must come before all fixed width tokens.
ErrorToken,
EndOfFileToken,
// Tokens
IdentifierName,
// LiteralTokens
RegularExpressionLiteral,
NumericLiteral,
StringLiteral,
// Template tokens
NoSubstitutionTemplateToken,
TemplateStartToken,
TemplateMiddleToken,
TemplateEndToken,
// All fixed width tokens follow.
// Keywords
BreakKeyword,
CaseKeyword,
CatchKeyword,
ContinueKeyword,
DebuggerKeyword,
DefaultKeyword,
DeleteKeyword,
DoKeyword,
ElseKeyword,
FalseKeyword,
FinallyKeyword,
ForKeyword,
FunctionKeyword,
IfKeyword,
InKeyword,
InstanceOfKeyword,
NewKeyword,
NullKeyword,
ReturnKeyword,
SwitchKeyword,
ThisKeyword,
ThrowKeyword,
TrueKeyword,
TryKeyword,
TypeOfKeyword,
VarKeyword,
VoidKeyword,
WhileKeyword,
WithKeyword,
// FutureReservedWords.
ClassKeyword,
ConstKeyword,
EnumKeyword,
ExportKeyword,
ExtendsKeyword,
ImportKeyword,
SuperKeyword,
// FutureReservedStrictWords.
ImplementsKeyword,
InterfaceKeyword,
LetKeyword,
PackageKeyword,
PrivateKeyword,
ProtectedKeyword,
PublicKeyword,
StaticKeyword,
YieldKeyword,
// TypeScript keywords.
AnyKeyword,
AsyncKeyword,
AwaitKeyword,
BooleanKeyword,
ConstructorKeyword,
DeclareKeyword,
GetKeyword,
ModuleKeyword,
RequireKeyword,
NumberKeyword,
SetKeyword,
TypeKeyword,
StringKeyword,
// Punctuators
OpenBraceToken,
CloseBraceToken,
OpenParenToken,
CloseParenToken,
OpenBracketToken,
CloseBracketToken,
DotToken,
DotDotDotToken,
SemicolonToken,
CommaToken,
LessThanToken,
GreaterThanToken,
LessThanEqualsToken,
GreaterThanEqualsToken,
EqualsEqualsToken,
EqualsGreaterThanToken,
ExclamationEqualsToken,
EqualsEqualsEqualsToken,
ExclamationEqualsEqualsToken,
PlusToken,
MinusToken,
AsteriskToken,
PercentToken,
PlusPlusToken,
MinusMinusToken,
LessThanLessThanToken,
GreaterThanGreaterThanToken,
GreaterThanGreaterThanGreaterThanToken,
AmpersandToken,
BarToken,
CaretToken,
ExclamationToken,
TildeToken,
AmpersandAmpersandToken,
BarBarToken,
QuestionToken,
ColonToken,
EqualsToken,
PlusEqualsToken,
MinusEqualsToken,
AsteriskEqualsToken,
PercentEqualsToken,
LessThanLessThanEqualsToken,
GreaterThanGreaterThanEqualsToken,
GreaterThanGreaterThanGreaterThanEqualsToken,
AmpersandEqualsToken,
BarEqualsToken,
CaretEqualsToken,
SlashToken,
SlashEqualsToken,
// SyntaxNodes
SourceUnit,
// Names
QualifiedName,
// Types
ObjectType,
FunctionType,
ArrayType,
ConstructorType,
GenericType,
TypeQuery,
TupleType,
UnionType,
ParenthesizedType,
// Module elements.
InterfaceDeclaration,
FunctionDeclaration,
ModuleDeclaration,
ClassDeclaration,
EnumDeclaration,
ImportDeclaration,
ExportAssignment,
// ClassElements
MethodDeclaration,
PropertyDeclaration,
ConstructorDeclaration,
// ClassElement and PropertyAssignment
GetAccessor,
SetAccessor,
// Type members.
PropertySignature,
CallSignature,
ConstructSignature,
IndexSignature,
MethodSignature,
// Statements
Block,
IfStatement,
VariableStatement,
ExpressionStatement,
ReturnStatement,
SwitchStatement,
BreakStatement,
ContinueStatement,
ForStatement,
ForInStatement,
EmptyStatement,
ThrowStatement,
WhileStatement,
TryStatement,
LabeledStatement,
DoStatement,
DebuggerStatement,
WithStatement,
// Expressions
PrefixUnaryExpression,
DeleteExpression,
TypeOfExpression,
VoidExpression,
ConditionalExpression,
BinaryExpression,
PostfixUnaryExpression,
PropertyAccessExpression,
InvocationExpression,
ArrayLiteralExpression,
ObjectLiteralExpression,
ObjectCreationExpression,
ParenthesizedExpression,
ParenthesizedArrowFunctionExpression,
SimpleArrowFunctionExpression,
TypeAssertionExpression,
ElementAccessExpression,
FunctionExpression,
OmittedExpression,
TemplateExpression,
TemplateAccessExpression,
YieldExpression,
AwaitExpression,
// Variable declarations
VariableDeclaration,
VariableDeclarator,
// Lists
ArgumentList,
ParameterList,
TypeArgumentList,
TypeParameterList,
// Clauses
HeritageClause,
EqualsValueClause,
CaseSwitchClause,
DefaultSwitchClause,
ElseClause,
CatchClause,
FinallyClause,
TemplateClause,
// Generics
TypeParameter,
Constraint,
// Misc.
Parameter,
EnumElement,
TypeAnnotation,
ExpressionBody,
ComputedPropertyName,
PropertyAssignment,
TypeAlias,
ExternalModuleReference,
ModuleNameModuleReference,
FirstStandardKeyword = BreakKeyword,
LastStandardKeyword = WithKeyword,
FirstFutureReservedKeyword = ClassKeyword,
LastFutureReservedKeyword = SuperKeyword,
FirstFutureReservedStrictKeyword = ImplementsKeyword,
LastFutureReservedStrictKeyword = YieldKeyword,
FirstTypeScriptKeyword = AnyKeyword,
LastTypeScriptKeyword = StringKeyword,
FirstKeyword = FirstStandardKeyword,
LastKeyword = LastTypeScriptKeyword,
FirstToken = ErrorToken,
LastToken = SlashEqualsToken,
FirstPunctuation = OpenBraceToken,
LastPunctuation = SlashEqualsToken,
FirstFixedWidth = FirstKeyword,
LastFixedWidth = LastPunctuation,
FirstTrivia = WhitespaceTrivia,
LastTrivia = SkippedTokenTrivia,
FirstNode = SourceUnit,
LastNode = ModuleNameModuleReference,
}
}

View file

@ -1,57 +0,0 @@
///<reference path='references.ts' />
interface Array<T> {
__data: number;
kind: TypeScript.SyntaxKind;
parent: TypeScript.ISyntaxElement;
}
module TypeScript {
export interface ISeparatedSyntaxList<T extends ISyntaxNodeOrToken> extends Array<ISyntaxNodeOrToken> {
//separatorCount(): number;
//separatorAt(index: number): TypeScript.ISyntaxToken;
//nonSeparatorCount(): number;
//nonSeparatorAt(index: number): T;
}
}
module TypeScript {
export function separatorCount(list: ISeparatedSyntaxList<ISyntaxNodeOrToken>) {
return list === undefined ? 0 : list.length >> 1;
}
export function nonSeparatorCount(list: ISeparatedSyntaxList<ISyntaxNodeOrToken>) {
return list === undefined ? 0 : (list.length + 1) >> 1;
}
export function separatorAt(list: ISeparatedSyntaxList<ISyntaxNodeOrToken>, index: number): ISyntaxToken {
return <ISyntaxToken>list[(index << 1) + 1];
}
export function nonSeparatorAt<T extends ISyntaxNodeOrToken>(list: ISeparatedSyntaxList<T>, index: number): T {
return <T>list[index << 1];
}
}
module TypeScript.Syntax {
function addArrayPrototypeValue(name: string, val: any) {
if (Object.defineProperty && (<any>Array.prototype)[name] === undefined) {
Object.defineProperty(Array.prototype, name, { value: val, writable: false, enumerable: false });
}
else {
(<any>Array.prototype)[name] = val;
}
}
addArrayPrototypeValue("kind", SyntaxKind.List);
export function list<T extends ISyntaxNodeOrToken>(nodes: T[]): T[] {
return nodes;
}
export function separatedList<T extends ISyntaxNodeOrToken>(nodesAndTokens: ISyntaxNodeOrToken[]): ISeparatedSyntaxList<T> {
return <ISeparatedSyntaxList<T>>nodesAndTokens;
}
}

View file

@ -1,39 +0,0 @@
///<reference path='references.ts' />
// A debug class that we use to make sure a syntax node is valid. Currently, this simply verifies
// that the same token does not appear in the tree multiple times. This is important for
// subsystems that want to map between tokens and positions. If a token shows up multiple times in
// the node, then it will not have a unique position, previous token, etc. etc. and that can screw
// many algorithms. For this reason, when generating trees, it is important that nodes that are
// reused are cloned before insertion.
module TypeScript {
export class SyntaxNodeInvariantsChecker extends SyntaxWalker {
private tokenTable = Collections.createHashTable(Collections.DefaultHashTableCapacity, Collections.identityHashCode);
public static checkInvariants(node: ISyntaxNode): void {
visitNodeOrToken(new SyntaxNodeInvariantsChecker(), node);
}
public visitNode(node: ISyntaxNode): void {
Debug.assert(node.kind === SyntaxKind.SourceUnit || node.parent);
super.visitNode(node);
}
public visitList(list: ISyntaxNodeOrToken[]): void {
Debug.assert(isShared(list) || list.parent);
super.visitList(list);
}
public visitSeparatedList(list: ISyntaxNodeOrToken[]): void {
Debug.assert(isShared(list) || list.parent);
super.visitSeparatedList(list);
}
public visitToken(token: ISyntaxToken): void {
// We're calling 'add', so the table will throw if we try to put the same token in multiple
// times.
Debug.assert(token.parent);
this.tokenTable.add(token, token);
}
}
}

View file

@ -1,8 +0,0 @@
///<reference path='references.ts' />
module TypeScript {
export interface ISyntaxNodeOrToken extends ISyntaxElement {
childCount: number;
childAt(index: number): ISyntaxElement;
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,495 +0,0 @@
///<reference path='references.ts' />
module TypeScript {
export interface SourceUnitSyntax extends ISyntaxNode {
syntaxTree: SyntaxTree;
moduleElements: IModuleElementSyntax[];
endOfFileToken: ISyntaxToken;
}
export interface QualifiedNameSyntax extends ISyntaxNode, INameSyntax {
left: INameSyntax;
dotToken: ISyntaxToken;
right: ISyntaxToken;
}
export interface ObjectTypeSyntax extends ISyntaxNode, ITypeSyntax {
openBraceToken: ISyntaxToken;
typeMembers: ISeparatedSyntaxList<ITypeMemberSyntax>;
closeBraceToken: ISyntaxToken;
}
export interface FunctionTypeSyntax extends ISyntaxNode, ITypeSyntax {
typeParameterList: TypeParameterListSyntax;
parameterList: ParameterListSyntax;
equalsGreaterThanToken: ISyntaxToken;
type: ITypeSyntax;
}
export interface ArrayTypeSyntax extends ISyntaxNode, ITypeSyntax {
type: ITypeSyntax;
openBracketToken: ISyntaxToken;
closeBracketToken: ISyntaxToken;
}
export interface ConstructorTypeSyntax extends ISyntaxNode, ITypeSyntax {
newKeyword: ISyntaxToken;
typeParameterList: TypeParameterListSyntax;
parameterList: ParameterListSyntax;
equalsGreaterThanToken: ISyntaxToken;
type: ITypeSyntax;
}
export interface GenericTypeSyntax extends ISyntaxNode, ITypeSyntax {
name: INameSyntax;
typeArgumentList: TypeArgumentListSyntax;
}
export interface TypeQuerySyntax extends ISyntaxNode, ITypeSyntax {
typeOfKeyword: ISyntaxToken;
name: INameSyntax;
}
export interface TupleTypeSyntax extends ISyntaxNode, ITypeSyntax {
openBracketToken: ISyntaxToken;
types: ISeparatedSyntaxList<ITypeSyntax>;
closeBracketToken: ISyntaxToken;
}
export interface UnionTypeSyntax extends ISyntaxNode, ITypeSyntax {
left: ITypeSyntax;
barToken: ISyntaxToken;
right: ITypeSyntax;
}
export interface ParenthesizedTypeSyntax extends ISyntaxNode, ITypeSyntax {
openParenToken: ISyntaxToken;
type: ITypeSyntax;
closeParenToken: ISyntaxToken;
}
export interface InterfaceDeclarationSyntax extends ISyntaxNode, IModuleElementSyntax {
modifiers: ISyntaxToken[];
interfaceKeyword: ISyntaxToken;
identifier: ISyntaxToken;
typeParameterList: TypeParameterListSyntax;
heritageClauses: HeritageClauseSyntax[];
body: ObjectTypeSyntax;
}
export interface FunctionDeclarationSyntax extends ISyntaxNode, IStatementSyntax {
modifiers: ISyntaxToken[];
functionKeyword: ISyntaxToken;
identifier: ISyntaxToken;
callSignature: CallSignatureSyntax;
block: BlockSyntax;
semicolonToken: ISyntaxToken;
}
export interface ModuleDeclarationSyntax extends ISyntaxNode, IModuleElementSyntax {
modifiers: ISyntaxToken[];
moduleKeyword: ISyntaxToken;
name: INameSyntax;
stringLiteral: ISyntaxToken;
openBraceToken: ISyntaxToken;
moduleElements: IModuleElementSyntax[];
closeBraceToken: ISyntaxToken;
}
export interface ClassDeclarationSyntax extends ISyntaxNode, IModuleElementSyntax {
modifiers: ISyntaxToken[];
classKeyword: ISyntaxToken;
identifier: ISyntaxToken;
typeParameterList: TypeParameterListSyntax;
heritageClauses: HeritageClauseSyntax[];
openBraceToken: ISyntaxToken;
classElements: IClassElementSyntax[];
closeBraceToken: ISyntaxToken;
}
export interface EnumDeclarationSyntax extends ISyntaxNode, IModuleElementSyntax {
modifiers: ISyntaxToken[];
enumKeyword: ISyntaxToken;
identifier: ISyntaxToken;
openBraceToken: ISyntaxToken;
enumElements: ISeparatedSyntaxList<EnumElementSyntax>;
closeBraceToken: ISyntaxToken;
}
export interface ImportDeclarationSyntax extends ISyntaxNode, IModuleElementSyntax {
modifiers: ISyntaxToken[];
importKeyword: ISyntaxToken;
identifier: ISyntaxToken;
equalsToken: ISyntaxToken;
moduleReference: IModuleReferenceSyntax;
semicolonToken: ISyntaxToken;
}
export interface ExportAssignmentSyntax extends ISyntaxNode, IModuleElementSyntax {
exportKeyword: ISyntaxToken;
equalsToken: ISyntaxToken;
identifier: ISyntaxToken;
semicolonToken: ISyntaxToken;
}
export interface MemberFunctionDeclarationSyntax extends ISyntaxNode, IMemberDeclarationSyntax {
modifiers: ISyntaxToken[];
propertyName: ISyntaxToken;
callSignature: CallSignatureSyntax;
block: BlockSyntax;
semicolonToken: ISyntaxToken;
}
export interface MemberVariableDeclarationSyntax extends ISyntaxNode, IMemberDeclarationSyntax {
modifiers: ISyntaxToken[];
variableDeclarator: VariableDeclaratorSyntax;
semicolonToken: ISyntaxToken;
}
export interface ConstructorDeclarationSyntax extends ISyntaxNode, IClassElementSyntax {
modifiers: ISyntaxToken[];
constructorKeyword: ISyntaxToken;
callSignature: CallSignatureSyntax;
block: BlockSyntax;
semicolonToken: ISyntaxToken;
}
export interface IndexMemberDeclarationSyntax extends ISyntaxNode, IClassElementSyntax {
modifiers: ISyntaxToken[];
indexSignature: IndexSignatureSyntax;
semicolonToken: ISyntaxToken;
}
export interface GetAccessorSyntax extends ISyntaxNode, IMemberDeclarationSyntax, IPropertyAssignmentSyntax {
modifiers: ISyntaxToken[];
getKeyword: ISyntaxToken;
propertyName: ISyntaxToken;
callSignature: CallSignatureSyntax;
block: BlockSyntax;
}
export interface SetAccessorSyntax extends ISyntaxNode, IMemberDeclarationSyntax, IPropertyAssignmentSyntax {
modifiers: ISyntaxToken[];
setKeyword: ISyntaxToken;
propertyName: ISyntaxToken;
callSignature: CallSignatureSyntax;
block: BlockSyntax;
}
export interface PropertySignatureSyntax extends ISyntaxNode, ITypeMemberSyntax {
propertyName: ISyntaxToken;
questionToken: ISyntaxToken;
typeAnnotation: TypeAnnotationSyntax;
}
export interface CallSignatureSyntax extends ISyntaxNode, ITypeMemberSyntax {
typeParameterList: TypeParameterListSyntax;
parameterList: ParameterListSyntax;
typeAnnotation: TypeAnnotationSyntax;
}
export interface ConstructSignatureSyntax extends ISyntaxNode, ITypeMemberSyntax {
newKeyword: ISyntaxToken;
callSignature: CallSignatureSyntax;
}
export interface IndexSignatureSyntax extends ISyntaxNode, ITypeMemberSyntax {
openBracketToken: ISyntaxToken;
parameters: ISeparatedSyntaxList<ParameterSyntax>;
closeBracketToken: ISyntaxToken;
typeAnnotation: TypeAnnotationSyntax;
}
export interface MethodSignatureSyntax extends ISyntaxNode, ITypeMemberSyntax {
propertyName: ISyntaxToken;
questionToken: ISyntaxToken;
callSignature: CallSignatureSyntax;
}
export interface BlockSyntax extends ISyntaxNode, IStatementSyntax {
openBraceToken: ISyntaxToken;
statements: IStatementSyntax[];
closeBraceToken: ISyntaxToken;
}
export interface IfStatementSyntax extends ISyntaxNode, IStatementSyntax {
ifKeyword: ISyntaxToken;
openParenToken: ISyntaxToken;
condition: IExpressionSyntax;
closeParenToken: ISyntaxToken;
statement: IStatementSyntax;
elseClause: ElseClauseSyntax;
}
export interface VariableStatementSyntax extends ISyntaxNode, IStatementSyntax {
modifiers: ISyntaxToken[];
variableDeclaration: VariableDeclarationSyntax;
semicolonToken: ISyntaxToken;
}
export interface ExpressionStatementSyntax extends ISyntaxNode, IStatementSyntax {
expression: IExpressionSyntax;
semicolonToken: ISyntaxToken;
}
export interface ReturnStatementSyntax extends ISyntaxNode, IStatementSyntax {
returnKeyword: ISyntaxToken;
expression: IExpressionSyntax;
semicolonToken: ISyntaxToken;
}
export interface SwitchStatementSyntax extends ISyntaxNode, IStatementSyntax {
switchKeyword: ISyntaxToken;
openParenToken: ISyntaxToken;
expression: IExpressionSyntax;
closeParenToken: ISyntaxToken;
openBraceToken: ISyntaxToken;
switchClauses: ISwitchClauseSyntax[];
closeBraceToken: ISyntaxToken;
}
export interface BreakStatementSyntax extends ISyntaxNode, IStatementSyntax {
breakKeyword: ISyntaxToken;
identifier: ISyntaxToken;
semicolonToken: ISyntaxToken;
}
export interface ContinueStatementSyntax extends ISyntaxNode, IStatementSyntax {
continueKeyword: ISyntaxToken;
identifier: ISyntaxToken;
semicolonToken: ISyntaxToken;
}
export interface ForStatementSyntax extends ISyntaxNode, IStatementSyntax {
forKeyword: ISyntaxToken;
openParenToken: ISyntaxToken;
variableDeclaration: VariableDeclarationSyntax;
initializer: IExpressionSyntax;
firstSemicolonToken: ISyntaxToken;
condition: IExpressionSyntax;
secondSemicolonToken: ISyntaxToken;
incrementor: IExpressionSyntax;
closeParenToken: ISyntaxToken;
statement: IStatementSyntax;
}
export interface ForInStatementSyntax extends ISyntaxNode, IStatementSyntax {
forKeyword: ISyntaxToken;
openParenToken: ISyntaxToken;
variableDeclaration: VariableDeclarationSyntax;
left: IExpressionSyntax;
inKeyword: ISyntaxToken;
expression: IExpressionSyntax;
closeParenToken: ISyntaxToken;
statement: IStatementSyntax;
}
export interface EmptyStatementSyntax extends ISyntaxNode, IStatementSyntax {
semicolonToken: ISyntaxToken;
}
export interface ThrowStatementSyntax extends ISyntaxNode, IStatementSyntax {
throwKeyword: ISyntaxToken;
expression: IExpressionSyntax;
semicolonToken: ISyntaxToken;
}
export interface WhileStatementSyntax extends ISyntaxNode, IStatementSyntax {
whileKeyword: ISyntaxToken;
openParenToken: ISyntaxToken;
condition: IExpressionSyntax;
closeParenToken: ISyntaxToken;
statement: IStatementSyntax;
}
export interface TryStatementSyntax extends ISyntaxNode, IStatementSyntax {
tryKeyword: ISyntaxToken;
block: BlockSyntax;
catchClause: CatchClauseSyntax;
finallyClause: FinallyClauseSyntax;
}
export interface LabeledStatementSyntax extends ISyntaxNode, IStatementSyntax {
identifier: ISyntaxToken;
colonToken: ISyntaxToken;
statement: IStatementSyntax;
}
export interface DoStatementSyntax extends ISyntaxNode, IStatementSyntax {
doKeyword: ISyntaxToken;
statement: IStatementSyntax;
whileKeyword: ISyntaxToken;
openParenToken: ISyntaxToken;
condition: IExpressionSyntax;
closeParenToken: ISyntaxToken;
semicolonToken: ISyntaxToken;
}
export interface DebuggerStatementSyntax extends ISyntaxNode, IStatementSyntax {
debuggerKeyword: ISyntaxToken;
semicolonToken: ISyntaxToken;
}
export interface WithStatementSyntax extends ISyntaxNode, IStatementSyntax {
withKeyword: ISyntaxToken;
openParenToken: ISyntaxToken;
condition: IExpressionSyntax;
closeParenToken: ISyntaxToken;
statement: IStatementSyntax;
}
export interface PrefixUnaryExpressionSyntax extends ISyntaxNode, IUnaryExpressionSyntax {
operatorToken: ISyntaxToken;
operand: IUnaryExpressionSyntax;
}
export interface DeleteExpressionSyntax extends ISyntaxNode, IUnaryExpressionSyntax {
deleteKeyword: ISyntaxToken;
expression: IUnaryExpressionSyntax;
}
export interface TypeOfExpressionSyntax extends ISyntaxNode, IUnaryExpressionSyntax {
typeOfKeyword: ISyntaxToken;
expression: IUnaryExpressionSyntax;
}
export interface VoidExpressionSyntax extends ISyntaxNode, IUnaryExpressionSyntax {
voidKeyword: ISyntaxToken;
expression: IUnaryExpressionSyntax;
}
export interface ConditionalExpressionSyntax extends ISyntaxNode, IExpressionSyntax {
condition: IExpressionSyntax;
questionToken: ISyntaxToken;
whenTrue: IExpressionSyntax;
colonToken: ISyntaxToken;
whenFalse: IExpressionSyntax;
}
export interface BinaryExpressionSyntax extends ISyntaxNode, IExpressionSyntax {
left: IExpressionSyntax;
operatorToken: ISyntaxToken;
right: IExpressionSyntax;
}
export interface PostfixUnaryExpressionSyntax extends ISyntaxNode, IPostfixExpressionSyntax {
operand: ILeftHandSideExpressionSyntax;
operatorToken: ISyntaxToken;
}
export interface MemberAccessExpressionSyntax extends ISyntaxNode, IMemberExpressionSyntax, ICallExpressionSyntax {
expression: ILeftHandSideExpressionSyntax;
dotToken: ISyntaxToken;
name: ISyntaxToken;
}
export interface InvocationExpressionSyntax extends ISyntaxNode, ICallExpressionSyntax {
expression: ILeftHandSideExpressionSyntax;
argumentList: ArgumentListSyntax;
}
export interface ArrayLiteralExpressionSyntax extends ISyntaxNode, IPrimaryExpressionSyntax {
openBracketToken: ISyntaxToken;
expressions: ISeparatedSyntaxList<IExpressionSyntax>;
closeBracketToken: ISyntaxToken;
}
export interface ObjectLiteralExpressionSyntax extends ISyntaxNode, IPrimaryExpressionSyntax {
openBraceToken: ISyntaxToken;
propertyAssignments: ISeparatedSyntaxList<IPropertyAssignmentSyntax>;
closeBraceToken: ISyntaxToken;
}
export interface ObjectCreationExpressionSyntax extends ISyntaxNode, IPrimaryExpressionSyntax {
newKeyword: ISyntaxToken;
expression: IMemberExpressionSyntax;
argumentList: ArgumentListSyntax;
}
export interface ParenthesizedExpressionSyntax extends ISyntaxNode, IPrimaryExpressionSyntax {
openParenToken: ISyntaxToken;
expression: IExpressionSyntax;
closeParenToken: ISyntaxToken;
}
export interface ParenthesizedArrowFunctionExpressionSyntax extends ISyntaxNode, IUnaryExpressionSyntax {
callSignature: CallSignatureSyntax;
equalsGreaterThanToken: ISyntaxToken;
block: BlockSyntax;
expression: IExpressionSyntax;
}
export interface SimpleArrowFunctionExpressionSyntax extends ISyntaxNode, IUnaryExpressionSyntax {
parameter: ParameterSyntax;
equalsGreaterThanToken: ISyntaxToken;
block: BlockSyntax;
expression: IExpressionSyntax;
}
export interface CastExpressionSyntax extends ISyntaxNode, IUnaryExpressionSyntax {
lessThanToken: ISyntaxToken;
type: ITypeSyntax;
greaterThanToken: ISyntaxToken;
expression: IUnaryExpressionSyntax;
}
export interface ElementAccessExpressionSyntax extends ISyntaxNode, IMemberExpressionSyntax, ICallExpressionSyntax {
expression: ILeftHandSideExpressionSyntax;
openBracketToken: ISyntaxToken;
argumentExpression: IExpressionSyntax;
closeBracketToken: ISyntaxToken;
}
export interface FunctionExpressionSyntax extends ISyntaxNode, IPrimaryExpressionSyntax {
functionKeyword: ISyntaxToken;
identifier: ISyntaxToken;
callSignature: CallSignatureSyntax;
block: BlockSyntax;
}
export interface OmittedExpressionSyntax extends ISyntaxNode, IExpressionSyntax {
}
export interface VariableDeclarationSyntax extends ISyntaxNode {
varKeyword: ISyntaxToken;
variableDeclarators: ISeparatedSyntaxList<VariableDeclaratorSyntax>;
}
export interface VariableDeclaratorSyntax extends ISyntaxNode {
propertyName: ISyntaxToken;
typeAnnotation: TypeAnnotationSyntax;
equalsValueClause: EqualsValueClauseSyntax;
}
export interface ArgumentListSyntax extends ISyntaxNode {
typeArgumentList: TypeArgumentListSyntax;
openParenToken: ISyntaxToken;
arguments: ISeparatedSyntaxList<IExpressionSyntax>;
closeParenToken: ISyntaxToken;
}
export interface ParameterListSyntax extends ISyntaxNode {
openParenToken: ISyntaxToken;
parameters: ISeparatedSyntaxList<ParameterSyntax>;
closeParenToken: ISyntaxToken;
}
export interface TypeArgumentListSyntax extends ISyntaxNode {
lessThanToken: ISyntaxToken;
typeArguments: ISeparatedSyntaxList<ITypeSyntax>;
greaterThanToken: ISyntaxToken;
}
export interface TypeParameterListSyntax extends ISyntaxNode {
lessThanToken: ISyntaxToken;
typeParameters: ISeparatedSyntaxList<TypeParameterSyntax>;
greaterThanToken: ISyntaxToken;
}
export interface HeritageClauseSyntax extends ISyntaxNode {
extendsOrImplementsKeyword: ISyntaxToken;
typeNames: ISeparatedSyntaxList<INameSyntax>;
}
export interface EqualsValueClauseSyntax extends ISyntaxNode {
equalsToken: ISyntaxToken;
value: IExpressionSyntax;
}
export interface CaseSwitchClauseSyntax extends ISyntaxNode, ISwitchClauseSyntax {
caseKeyword: ISyntaxToken;
expression: IExpressionSyntax;
colonToken: ISyntaxToken;
statements: IStatementSyntax[];
}
export interface DefaultSwitchClauseSyntax extends ISyntaxNode, ISwitchClauseSyntax {
defaultKeyword: ISyntaxToken;
colonToken: ISyntaxToken;
statements: IStatementSyntax[];
}
export interface ElseClauseSyntax extends ISyntaxNode {
elseKeyword: ISyntaxToken;
statement: IStatementSyntax;
}
export interface CatchClauseSyntax extends ISyntaxNode {
catchKeyword: ISyntaxToken;
openParenToken: ISyntaxToken;
identifier: ISyntaxToken;
typeAnnotation: TypeAnnotationSyntax;
closeParenToken: ISyntaxToken;
block: BlockSyntax;
}
export interface FinallyClauseSyntax extends ISyntaxNode {
finallyKeyword: ISyntaxToken;
block: BlockSyntax;
}
export interface TypeParameterSyntax extends ISyntaxNode {
identifier: ISyntaxToken;
constraint: ConstraintSyntax;
}
export interface ConstraintSyntax extends ISyntaxNode {
extendsKeyword: ISyntaxToken;
typeOrExpression: ISyntaxNodeOrToken;
}
export interface SimplePropertyAssignmentSyntax extends ISyntaxNode, IPropertyAssignmentSyntax {
propertyName: ISyntaxToken;
colonToken: ISyntaxToken;
expression: IExpressionSyntax;
}
export interface FunctionPropertyAssignmentSyntax extends ISyntaxNode, IPropertyAssignmentSyntax {
propertyName: ISyntaxToken;
callSignature: CallSignatureSyntax;
block: BlockSyntax;
}
export interface ParameterSyntax extends ISyntaxNode {
dotDotDotToken: ISyntaxToken;
modifiers: ISyntaxToken[];
identifier: ISyntaxToken;
questionToken: ISyntaxToken;
typeAnnotation: TypeAnnotationSyntax;
equalsValueClause: EqualsValueClauseSyntax;
}
export interface EnumElementSyntax extends ISyntaxNode {
propertyName: ISyntaxToken;
equalsValueClause: EqualsValueClauseSyntax;
}
export interface TypeAnnotationSyntax extends ISyntaxNode {
colonToken: ISyntaxToken;
type: ITypeSyntax;
}
export interface ExternalModuleReferenceSyntax extends ISyntaxNode, IModuleReferenceSyntax {
requireKeyword: ISyntaxToken;
openParenToken: ISyntaxToken;
stringLiteral: ISyntaxToken;
closeParenToken: ISyntaxToken;
}
export interface ModuleNameModuleReferenceSyntax extends ISyntaxNode, IModuleReferenceSyntax {
moduleName: INameSyntax;
}
}

View file

@ -1,470 +0,0 @@
///<reference path='references.ts' />
module TypeScript {
export interface ISyntaxToken extends ISyntaxNodeOrToken, INameSyntax, IPrimaryExpressionSyntax, IPropertyAssignmentSyntax, IPropertyNameSyntax {
// Adjusts the full start of this token. Should only be called by the parser.
setFullStart(fullStart: number): void;
// The absolute start of this element, including the leading trivia.
fullStart(): number;
// With of this element, including leading and trailing trivia.
fullWidth(): number;
// Text for this token, not including leading or trailing trivia.
text(): string;
fullText(text?: ISimpleText): string;
hasLeadingTrivia(): boolean;
hasLeadingNewLine(): boolean;
hasLeadingComment(): boolean;
hasLeadingSkippedToken(): boolean;
leadingTrivia(text?: ISimpleText): ISyntaxTriviaList;
leadingTriviaWidth(text?: ISimpleText): number;
// True if this was a keyword that the parser converted to an identifier. i.e. if you have
// x.public
//
// then 'public' will be converted to an identifier. These tokens should are parser
// generated and, as such, should not be returned when the incremental parser source
// hands out tokens. Note: If it is included in a node then *that* node may still
// be reusuable. i.e. if i have: private Foo() { x.public = 1; }
//
// Then that entire method node is reusable even if the 'public' identifier is not.
isKeywordConvertedToIdentifier(): boolean;
// True if this element cannot be reused in incremental parsing. There are several situations
// in which an element can not be reused. They are:
//
// 1) The element contained skipped text.
// 2) The element contained zero width tokens.
// 3) The element contains tokens generated by the parser (like >> or a keyword -> identifier
// conversion).
// 4) The element contains a regex token somewhere under it. A regex token is either a
// regex itself (i.e. /foo/), or is a token which could start a regex (i.e. "/" or "/="). This
// data is used by the incremental parser to decide if a node can be reused. Due to the
// lookahead nature of regex tokens, a node containing a regex token cannot be reused. Normally,
// changes to text only affect the tokens directly intersected. However, because regex tokens
// have such unbounded lookahead (technically bounded at the end of a line, but htat's minor),
// we need to recheck them to see if they've changed due to the edit. For example, if you had:
//
// while (true) /3; return;
//
// And you changed it to:
//
// while (true) /3; return/;
//
// Then even though only the 'return' and ';' colons were touched, we'd want to rescan the '/'
// token which we would then realize was a regex.
isIncrementallyUnusable(): boolean;
clone(): ISyntaxToken;
}
}
module TypeScript {
export function tokenValue(token: ISyntaxToken): any {
if (token.fullWidth() === 0) {
return undefined;
}
var kind = token.kind;
var text = token.text();
if (kind === SyntaxKind.IdentifierName) {
return massageEscapes(text);
}
switch (kind) {
case SyntaxKind.TrueKeyword:
return true;
case SyntaxKind.FalseKeyword:
return false;
case SyntaxKind.NullKeyword:
return undefined;
}
if (SyntaxFacts.isAnyKeyword(kind) || SyntaxFacts.isAnyPunctuation(kind)) {
return SyntaxFacts.getText(kind);
}
if (kind === SyntaxKind.NumericLiteral) {
return IntegerUtilities.isHexInteger(text) ? parseInt(text, /*radix:*/ 16) : parseFloat(text);
}
else if (kind === SyntaxKind.StringLiteral) {
return (text.length > 1 && text.charCodeAt(text.length - 1) === text.charCodeAt(0))
? massageEscapes(text.substr(1, text.length - "''".length))
: massageEscapes(text.substr(1));
}
else if (kind === SyntaxKind.NoSubstitutionTemplateToken || kind === SyntaxKind.TemplateEndToken) {
// Both of these template types may be missing their closing backtick (if they were at
// the end of the file). Check to make sure it is there before grabbing the portion
// we're examining.
return (text.length > 1 && text.charCodeAt(text.length - 1) === CharacterCodes.backtick)
? massageTemplate(text.substr(1, text.length - "``".length))
: massageTemplate(text.substr(1));
}
else if (kind === SyntaxKind.TemplateStartToken || kind === SyntaxKind.TemplateMiddleToken) {
// Both these tokens must have been properly ended. i.e. if it didn't end with a ${
// then we would not have parsed a start or middle token out at all. So we don't
// need to check for an incomplete token.
return massageTemplate(text.substr(1, text.length - "`${".length));
}
else if (kind === SyntaxKind.RegularExpressionLiteral) {
return regularExpressionValue(text);
}
else if (kind === SyntaxKind.EndOfFileToken || kind === SyntaxKind.ErrorToken) {
return undefined;
}
else {
throw Errors.invalidOperation();
}
}
export function tokenValueText(token: ISyntaxToken): string {
var value = tokenValue(token);
return value === undefined ? "" : massageDisallowedIdentifiers(value.toString());
}
function massageTemplate(text: string): string {
// First, convert all carriage-return newlines into line-feed newlines. This is due to:
//
// The TRV of LineTerminatorSequence :: <CR> is the code unit value 0x000A.
// ...
// The TRV of LineTerminatorSequence :: <CR><LF> is the sequence consisting of the code unit value 0x000A.
text = text.replace("\r\n", "\n").replace("\r", "\n");
// Now remove any escape characters that may be in the string.
return massageEscapes(text);
}
export function massageEscapes(text: string): string {
return text.indexOf("\\") >= 0 ? convertEscapes(text) : text;
}
function regularExpressionValue(text: string): RegExp {
try {
var lastSlash = text.lastIndexOf("/");
var body = text.substring(1, lastSlash);
var flags = text.substring(lastSlash + 1);
return new RegExp(body, flags);
}
catch (e) {
return undefined;
}
}
function massageDisallowedIdentifiers(text: string): string {
// We routinely store the 'valueText' for a token as keys in dictionaries. However, as those
// dictionaries are usually just a javascript object, we run into issues when teh keys collide
// with certain predefined keys they depend on (like __proto__). To workaround this
// we ensure that the valueText of any token is not __proto__ but is instead ___proto__.
//
// We also prepend a _ to any identifier starting with two __ . That allows us to carve
// out the entire namespace of identifiers starting with __ for ourselves.
if (text.charCodeAt(0) === CharacterCodes._ && text.charCodeAt(1) === CharacterCodes._) {
return "_" + text;
}
return text;
}
var characterArray: number[] = [];
function convertEscapes(text: string): string {
characterArray.length = 0;
var result = "";
for (var i = 0, n = text.length; i < n; i++) {
var ch = text.charCodeAt(i);
if (ch === CharacterCodes.backslash) {
i++;
if (i < n) {
ch = text.charCodeAt(i);
switch (ch) {
case CharacterCodes._0:
characterArray.push(CharacterCodes.nullCharacter);
continue;
case CharacterCodes.b:
characterArray.push(CharacterCodes.backspace);
continue;
case CharacterCodes.f:
characterArray.push(CharacterCodes.formFeed);
continue;
case CharacterCodes.n:
characterArray.push(CharacterCodes.lineFeed);
continue;
case CharacterCodes.r:
characterArray.push(CharacterCodes.carriageReturn);
continue;
case CharacterCodes.t:
characterArray.push(CharacterCodes.tab);
continue;
case CharacterCodes.v:
characterArray.push(CharacterCodes.verticalTab);
continue;
case CharacterCodes.x:
characterArray.push(hexValue(text, /*start:*/ i + 1, /*length:*/ 2));
i += 2;
continue;
case CharacterCodes.u:
characterArray.push(hexValue(text, /*start:*/ i + 1, /*length:*/ 4));
i += 4;
continue;
case CharacterCodes.carriageReturn:
var nextIndex = i + 1;
if (nextIndex < text.length && text.charCodeAt(nextIndex) === CharacterCodes.lineFeed) {
// Skip the entire \r\n sequence.
i++;
}
continue;
case CharacterCodes.lineFeed:
case CharacterCodes.paragraphSeparator:
case CharacterCodes.lineSeparator:
// From ES5: LineContinuation is the empty character sequence.
continue;
default:
// Any other character is ok as well. As per rule:
// EscapeSequence :: CharacterEscapeSequence
// CharacterEscapeSequence :: NonEscapeCharacter
// NonEscapeCharacter :: SourceCharacter but notEscapeCharacter or LineTerminator
//
// Intentional fall through
}
}
}
characterArray.push(ch);
if (i && !(i % 1024)) {
result = result.concat(String.fromCharCode.apply(undefined, characterArray));
characterArray.length = 0;
}
}
if (characterArray.length) {
result = result.concat(String.fromCharCode.apply(undefined, characterArray));
}
return result;
}
function hexValue(text: string, start: number, length: number): number {
var intChar = 0;
for (var i = 0; i < length; i++) {
var ch2 = text.charCodeAt(start + i);
if (!CharacterInfo.isHexDigit(ch2)) {
break;
}
intChar = (intChar << 4) + CharacterInfo.hexValue(ch2);
}
return intChar;
}
}
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());
}
export function convertKeywordToIdentifier(token: ISyntaxToken): ISyntaxToken {
return new ConvertedKeywordToken(token);
}
export function withLeadingTrivia(token: ISyntaxToken, leadingTrivia: ISyntaxTriviaList, text: ISimpleText): ISyntaxToken {
return new RealizedToken(token.fullStart(), token.kind, token.isKeywordConvertedToIdentifier(), leadingTrivia, token.text());
}
export function emptyToken(kind: SyntaxKind, fullStart: number): ISyntaxToken {
return new EmptyToken(kind, fullStart);
}
class EmptyToken implements ISyntaxToken {
public _primaryExpressionBrand: any; public _memberExpressionBrand: any; public _leftHandSideExpressionBrand: any; public _postfixExpressionBrand: any; public _unaryExpressionBrand: any; public _expressionBrand: any; public _typeBrand: any; public _nameBrand: any; public _propertyAssignmentBrand: any; public _propertyNameBrand: any;
public parent: ISyntaxElement;
public childCount: number;
constructor(public kind: SyntaxKind, private _fullStart: number) {
Debug.assert(!isNaN(_fullStart));
}
public setFullStart(fullStart: number): void {
this._fullStart = fullStart;
}
public childAt(index: number): ISyntaxElement { throw Errors.invalidOperation() }
public clone(): ISyntaxToken {
return new EmptyToken(this.kind, this._fullStart);
}
// Empty tokens are never incrementally reusable.
public isIncrementallyUnusable() { return true; }
public isKeywordConvertedToIdentifier() {
return false;
}
public fullWidth() { return 0; }
public fullStart(): number { return this._fullStart; }
public text() { return ""; }
public fullText(): string { return ""; }
public hasLeadingTrivia() { return false; }
public hasLeadingNewLine() { return false; }
public hasLeadingComment() { return false; }
public hasLeadingSkippedToken() { return false; }
public leadingTriviaWidth() { return 0; }
public leadingTrivia(): ISyntaxTriviaList { return Syntax.emptyTriviaList; }
}
EmptyToken.prototype.childCount = 0;
class RealizedToken implements ISyntaxToken {
public _primaryExpressionBrand: any; public _memberExpressionBrand: any; public _leftHandSideExpressionBrand: any; public _postfixExpressionBrand: any; public _unaryExpressionBrand: any; public _expressionBrand: any; public _typeBrand: any; public _nameBrand: any; public _propertyAssignmentBrand: any; public _propertyNameBrand: any;
private _isKeywordConvertedToIdentifier: boolean;
private _leadingTrivia: ISyntaxTriviaList;
private _text: string;
public parent: ISyntaxElement;
public childCount: number;
constructor(private _fullStart: number,
public kind: SyntaxKind,
isKeywordConvertedToIdentifier: boolean,
leadingTrivia: ISyntaxTriviaList,
text: string) {
Debug.assert(!isNaN(_fullStart));
this._isKeywordConvertedToIdentifier = isKeywordConvertedToIdentifier;
this._text = text;
this._leadingTrivia = leadingTrivia.clone();
if (!this._leadingTrivia.isShared()) {
this._leadingTrivia.parent = this;
}
}
public setFullStart(fullStart: number): void {
this._fullStart = fullStart;
}
public childAt(index: number): ISyntaxElement { throw Errors.invalidOperation() }
public clone(): ISyntaxToken {
return new RealizedToken(this._fullStart, this.kind, this._isKeywordConvertedToIdentifier, this._leadingTrivia, this._text);
}
// Realized tokens are created from the parser. They are *never* incrementally reusable.
public isIncrementallyUnusable() { return true; }
public isKeywordConvertedToIdentifier() {
return this._isKeywordConvertedToIdentifier;
}
public fullStart(): number { return this._fullStart; }
public fullWidth(): number { return this._leadingTrivia.fullWidth() + this._text.length; }
public text(): string { return this._text; }
public fullText(): string { return this._leadingTrivia.fullText() + this.text(); }
public hasLeadingTrivia(): boolean { return this._leadingTrivia.count() > 0; }
public hasLeadingNewLine(): boolean { return this._leadingTrivia.hasNewLine(); }
public hasLeadingComment(): boolean { return this._leadingTrivia.hasComment(); }
public hasLeadingSkippedToken(): boolean { return this._leadingTrivia.hasSkippedToken(); }
public leadingTrivia(): ISyntaxTriviaList { return this._leadingTrivia; }
public leadingTriviaWidth(): number { return this._leadingTrivia.fullWidth(); }
}
RealizedToken.prototype.childCount = 0;
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 _nameBrand: any; public _propertyAssignmentBrand: any; public _propertyNameBrand: any;
public parent: ISyntaxElement;
public kind: SyntaxKind;
public childCount: number;
constructor(private underlyingToken: ISyntaxToken) {
}
public setFullStart(fullStart: number): void {
this.underlyingToken.setFullStart(fullStart);
}
public childAt(index: number): ISyntaxElement { throw Errors.invalidOperation() }
public fullStart(): number {
return this.underlyingToken.fullStart();
}
public fullWidth(): number {
return this.underlyingToken.fullWidth();
}
public text(): string {
return this.underlyingToken.text();
}
private syntaxTreeText(text: ISimpleText) {
var result = text || syntaxTree(this).text;
Debug.assert(result);
return result;
}
public fullText(text?: ISimpleText): string {
return this.underlyingToken.fullText(this.syntaxTreeText(text));
}
public hasLeadingTrivia(): boolean { return this.underlyingToken.hasLeadingTrivia(); }
public hasLeadingNewLine(): boolean { return this.underlyingToken.hasLeadingNewLine(); }
public hasLeadingComment(): boolean { return this.underlyingToken.hasLeadingComment(); }
public hasLeadingSkippedToken(): boolean { return this.underlyingToken.hasLeadingSkippedToken(); }
public leadingTrivia(text?: ISimpleText): ISyntaxTriviaList {
var result = this.underlyingToken.leadingTrivia(this.syntaxTreeText(text));
result.parent = this;
return result;
}
public leadingTriviaWidth(text?: ISimpleText): number {
return this.underlyingToken.leadingTriviaWidth(this.syntaxTreeText(text));
}
public isKeywordConvertedToIdentifier(): boolean {
return true;
}
public isIncrementallyUnusable(): boolean {
// We're incrementally unusable if our underlying token is unusable.
// For example, we may have: this.public \
// In this case we will keyword converted to an identifier that is still unusable because
// it has a trailing skipped token.
return this.underlyingToken.isIncrementallyUnusable();
}
public clone(): ISyntaxToken {
return new ConvertedKeywordToken(this.underlyingToken);
}
}
ConvertedKeywordToken.prototype.kind = SyntaxKind.IdentifierName;
ConvertedKeywordToken.prototype.childCount = 0;
}

File diff suppressed because it is too large Load diff

View file

@ -1,174 +0,0 @@
///<reference path='references.ts' />
module TypeScript {
export interface ISyntaxTrivia {
parent: ISyntaxTriviaList;
kind: SyntaxKind;
isWhitespace(): boolean;
isComment(): boolean;
isNewLine(): boolean;
isSkippedToken(): boolean;
fullStart(): number;
fullWidth(): number;
// Text for this trivia.
fullText(): string;
// If this is a skipped token trivia, then this was the token that was skipped.
skippedToken(): ISyntaxToken;
clone(): ISyntaxTrivia;
}
}
module TypeScript.Syntax {
class AbstractTrivia implements ISyntaxTrivia {
public parent: ISyntaxTriviaList;
constructor(public kind: SyntaxKind) {
}
public clone(): ISyntaxTrivia {
throw Errors.abstract();
}
public fullStart(): number {
throw Errors.abstract();
}
public fullWidth(): number {
throw Errors.abstract();
}
public fullText(): string {
throw Errors.abstract();
}
public skippedToken(): ISyntaxToken {
throw Errors.abstract();
}
public isWhitespace(): boolean {
return this.kind === SyntaxKind.WhitespaceTrivia;
}
public isComment(): boolean {
return this.kind === SyntaxKind.SingleLineCommentTrivia || this.kind === SyntaxKind.MultiLineCommentTrivia;
}
public isNewLine(): boolean {
return this.kind === SyntaxKind.NewLineTrivia;
}
public isSkippedToken(): boolean {
return this.kind === SyntaxKind.SkippedTokenTrivia;
}
}
class SkippedTokenTrivia extends AbstractTrivia {
constructor(private _skippedToken: ISyntaxToken, private _fullText: string) {
super(SyntaxKind.SkippedTokenTrivia);
_skippedToken.parent = <ISyntaxElement><any>this;
}
public clone(): ISyntaxTrivia {
return new SkippedTokenTrivia(this._skippedToken.clone(), this._fullText);
}
public fullStart(): number {
return this._skippedToken.fullStart();
}
public fullWidth(): number {
return this.fullText().length;
}
public fullText(): string {
return this._fullText;
}
public skippedToken(): ISyntaxToken {
return this._skippedToken;
}
}
class DeferredTrivia extends AbstractTrivia {
constructor(kind: SyntaxKind, private _text: ISimpleText, private _fullStart: number, private _fullWidth: number) {
super(kind);
}
public clone(): ISyntaxTrivia {
return new DeferredTrivia(this.kind, this._text, this._fullStart, this._fullWidth);
}
public fullStart(): number {
return this._fullStart;
}
public fullWidth(): number {
return this._fullWidth;
}
public fullText(): string {
return this._text.substr(this._fullStart, this._fullWidth);
}
public skippedToken(): ISyntaxToken {
throw Errors.invalidOperation();
}
}
export function deferredTrivia(kind: SyntaxKind, text: ISimpleText, fullStart: number, fullWidth: number): ISyntaxTrivia {
return new DeferredTrivia(kind, text, fullStart, fullWidth);
}
export function skippedTokenTrivia(token: ISyntaxToken, text: ISimpleText): ISyntaxTrivia {
Debug.assert(!token.hasLeadingTrivia());
Debug.assert(token.fullWidth() > 0);
return new SkippedTokenTrivia(token, token.fullText(text));
}
// Breaks a multiline trivia up into individual line components. If the trivia doesn't span
// any lines, then the result will be a single string with the entire text of the trivia.
// Otherwise, there will be one entry in the array for each line spanned by the trivia. Each
// entry will contain the line separator at the end of the string.
export function splitMultiLineCommentTriviaIntoMultipleLines(trivia: ISyntaxTrivia): string[] {
// Debug.assert(trivia.kind === SyntaxKind.MultiLineCommentTrivia);
var result: string[] = [];
var triviaText = trivia.fullText();
var currentIndex = 0;
for (var i = 0; i < triviaText.length; i++) {
var ch = triviaText.charCodeAt(i);
// When we run into a newline for the first time, create the string builder and copy
// all the values up to this newline into it.
switch (ch) {
case CharacterCodes.carriageReturn:
if (i < triviaText.length - 1 && triviaText.charCodeAt(i + 1) === CharacterCodes.lineFeed) {
// Consume the \r
i++;
}
// Fall through.
case CharacterCodes.lineFeed:
case CharacterCodes.paragraphSeparator:
case CharacterCodes.lineSeparator:
// Eat from the last starting position through to the end of the newline.
result.push(triviaText.substring(currentIndex, i + 1));
// Set the current index to *after* the newline.
currentIndex = i + 1;
continue;
}
}
result.push(triviaText.substring(currentIndex));
return result;
}
}

View file

@ -1,234 +0,0 @@
///<reference path='references.ts' />
module TypeScript {
export interface ISyntaxTriviaList {
parent?: ISyntaxToken;
isShared(): boolean;
count(): number;
syntaxTriviaAt(index: number): ISyntaxTrivia;
// With of this trivia list.
fullWidth(): number;
// Text for this trivia list.
fullText(): string;
hasComment(): boolean;
hasNewLine(): boolean;
hasSkippedToken(): boolean;
last(): ISyntaxTrivia;
toArray(): ISyntaxTrivia[];
clone(): ISyntaxTriviaList;
}
}
module TypeScript.Syntax {
class EmptyTriviaList implements ISyntaxTriviaList {
public isShared(): boolean {
return true;
}
public count(): number {
return 0;
}
public syntaxTriviaAt(index: number): ISyntaxTrivia {
throw Errors.argumentOutOfRange("index");
}
public last(): ISyntaxTrivia {
throw Errors.argumentOutOfRange("index");
}
public fullWidth(): number {
return 0;
}
public fullText(): string {
return "";
}
public hasComment(): boolean {
return false;
}
public hasNewLine(): boolean {
return false;
}
public hasSkippedToken(): boolean {
return false;
}
public toArray(): ISyntaxTrivia[] {
return [];
}
public clone() {
return this;
}
};
export var emptyTriviaList: ISyntaxTriviaList = new EmptyTriviaList();
function isComment(trivia: ISyntaxTrivia): boolean {
return trivia.kind === SyntaxKind.MultiLineCommentTrivia || trivia.kind === SyntaxKind.SingleLineCommentTrivia;
}
class SingletonSyntaxTriviaList implements ISyntaxTriviaList {
private item: ISyntaxTrivia;
constructor(item: ISyntaxTrivia) {
this.item = item.clone();
this.item.parent = this;
}
public isShared(): boolean {
return false;
}
public count(): number {
return 1;
}
public syntaxTriviaAt(index: number): ISyntaxTrivia {
if (index !== 0) {
throw Errors.argumentOutOfRange("index");
}
return this.item;
}
public last(): ISyntaxTrivia {
return this.item;
}
public fullWidth(): number {
return this.item.fullWidth();
}
public fullText(): string {
return this.item.fullText();
}
public hasComment(): boolean {
return isComment(this.item);
}
public hasNewLine(): boolean {
return this.item.kind === SyntaxKind.NewLineTrivia;
}
public hasSkippedToken(): boolean {
return this.item.kind === SyntaxKind.SkippedTokenTrivia;
}
public toArray(): ISyntaxTrivia[] {
return [this.item];
}
public clone(): ISyntaxTriviaList {
return new SingletonSyntaxTriviaList(this.item.clone());
}
}
class NormalSyntaxTriviaList implements ISyntaxTriviaList {
private trivia: ISyntaxTrivia[];
constructor(trivia: ISyntaxTrivia[]) {
this.trivia = trivia.map(t => {
var cloned = t.clone();
cloned.parent = this;
return cloned;
});
}
public isShared(): boolean {
return false;
}
public count() {
return this.trivia.length;
}
public syntaxTriviaAt(index: number): ISyntaxTrivia {
if (index < 0 || index >= this.trivia.length) {
throw Errors.argumentOutOfRange("index");
}
return this.trivia[index];
}
public last(): ISyntaxTrivia {
return this.trivia[this.trivia.length - 1];
}
public fullWidth(): number {
return ArrayUtilities.sum(this.trivia, t => t.fullWidth());
}
public fullText(): string {
var result: string[] = [];
for (var i = 0, n = this.trivia.length; i < n; i++) {
result.push(this.trivia[i].fullText());
}
return result.join("");
}
public hasComment(): boolean {
for (var i = 0; i < this.trivia.length; i++) {
if (isComment(this.trivia[i])) {
return true;
}
}
return false;
}
public hasNewLine(): boolean {
for (var i = 0; i < this.trivia.length; i++) {
if (this.trivia[i].kind === SyntaxKind.NewLineTrivia) {
return true;
}
}
return false;
}
public hasSkippedToken(): boolean {
for (var i = 0; i < this.trivia.length; i++) {
if (this.trivia[i].kind === SyntaxKind.SkippedTokenTrivia) {
return true;
}
}
return false;
}
public toArray(): ISyntaxTrivia[] {
return this.trivia.slice(0);
}
public clone(): ISyntaxTriviaList {
return new NormalSyntaxTriviaList(this.trivia.map(t => t.clone()));
}
}
export function triviaList(trivia: ISyntaxTrivia[]): ISyntaxTriviaList {
if (!trivia || trivia.length === 0) {
return Syntax.emptyTriviaList;
}
if (trivia.length === 1) {
return new SingletonSyntaxTriviaList(trivia[0]);
}
return new NormalSyntaxTriviaList(trivia);
}
}

View file

@ -1,212 +0,0 @@
///<reference path='references.ts' />
module TypeScript {
export function childCount(element: ISyntaxElement): number {
if (isList(element)) { return (<ISyntaxNodeOrToken[]>element).length; }
return (<ISyntaxNodeOrToken>element).childCount;
}
export function childAt(element: ISyntaxElement, index: number): ISyntaxElement {
if (isList(element)) { return (<ISyntaxNodeOrToken[]>element)[index]; }
return (<ISyntaxNodeOrToken>element).childAt(index);
}
interface ISyntaxNodeInternal extends ISyntaxNode {
__cachedTokens: ISyntaxToken[];
}
class TokenCollectorWalker extends SyntaxWalker {
public tokens: ISyntaxToken[] = [];
public visitToken(token: ISyntaxToken): void {
this.tokens.push(token);
}
}
var tokenCollectorWalker = new TokenCollectorWalker();
export function getTokens(node: ISyntaxNode): ISyntaxToken[] {
var tokens = (<ISyntaxNodeInternal>node).__cachedTokens;
if (!tokens) {
tokens = [];
tokenCollectorWalker.tokens = tokens;
visitNodeOrToken(tokenCollectorWalker, node);
(<ISyntaxNodeInternal>node).__cachedTokens = tokens;
tokenCollectorWalker.tokens = undefined;
}
return tokens;
}
export module SyntaxUtilities {
export function isAnyFunctionExpressionOrDeclaration(ast: ISyntaxElement): boolean {
switch (ast.kind) {
case SyntaxKind.SimpleArrowFunctionExpression:
case SyntaxKind.ParenthesizedArrowFunctionExpression:
case SyntaxKind.FunctionExpression:
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.MethodDeclaration:
case SyntaxKind.ConstructorDeclaration:
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
return true;
}
return false;
}
export function isLeftHandSizeExpression(element: ISyntaxElement) {
if (element) {
switch (element.kind) {
case SyntaxKind.PropertyAccessExpression:
case SyntaxKind.ElementAccessExpression:
case SyntaxKind.TemplateAccessExpression:
case SyntaxKind.ObjectCreationExpression:
case SyntaxKind.InvocationExpression:
case SyntaxKind.ArrayLiteralExpression:
case SyntaxKind.ParenthesizedExpression:
case SyntaxKind.ObjectLiteralExpression:
case SyntaxKind.FunctionExpression:
case SyntaxKind.IdentifierName:
case SyntaxKind.RegularExpressionLiteral:
case SyntaxKind.NumericLiteral:
case SyntaxKind.StringLiteral:
case SyntaxKind.FalseKeyword:
case SyntaxKind.NullKeyword:
case SyntaxKind.ThisKeyword:
case SyntaxKind.TrueKeyword:
case SyntaxKind.SuperKeyword:
return true;
}
}
return false;
}
export function isSwitchClause(element: ISyntaxElement) {
if (element) {
switch (element.kind) {
case SyntaxKind.CaseSwitchClause:
case SyntaxKind.DefaultSwitchClause:
return true;
}
}
return false;
}
export function isTypeMember(element: ISyntaxElement) {
if (element) {
switch (element.kind) {
case SyntaxKind.ConstructSignature:
case SyntaxKind.MethodSignature:
case SyntaxKind.IndexSignature:
case SyntaxKind.PropertySignature:
case SyntaxKind.CallSignature:
return true;
}
}
return false;
}
export function isClassElement(element: ISyntaxElement) {
if (element) {
switch (element.kind) {
case SyntaxKind.ConstructorDeclaration:
case SyntaxKind.IndexSignature:
case SyntaxKind.MethodDeclaration:
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
case SyntaxKind.PropertyDeclaration:
return true;
}
}
return false;
}
export function isModuleElement(element: ISyntaxElement) {
if (element) {
switch (element.kind) {
case SyntaxKind.ImportDeclaration:
case SyntaxKind.ExportAssignment:
case SyntaxKind.ClassDeclaration:
case SyntaxKind.InterfaceDeclaration:
case SyntaxKind.ModuleDeclaration:
case SyntaxKind.EnumDeclaration:
// Keep in sync with isStatement:
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.VariableStatement:
case SyntaxKind.Block:
case SyntaxKind.IfStatement:
case SyntaxKind.ExpressionStatement:
case SyntaxKind.ThrowStatement:
case SyntaxKind.ReturnStatement:
case SyntaxKind.SwitchStatement:
case SyntaxKind.BreakStatement:
case SyntaxKind.ContinueStatement:
case SyntaxKind.ForInStatement:
case SyntaxKind.ForStatement:
case SyntaxKind.WhileStatement:
case SyntaxKind.WithStatement:
case SyntaxKind.EmptyStatement:
case SyntaxKind.TryStatement:
case SyntaxKind.LabeledStatement:
case SyntaxKind.DoStatement:
case SyntaxKind.DebuggerStatement:
return true;
}
}
return false;
}
export function isStatement(element: ISyntaxElement) {
if (element) {
switch (element.kind) {
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.VariableStatement:
case SyntaxKind.Block:
case SyntaxKind.IfStatement:
case SyntaxKind.ExpressionStatement:
case SyntaxKind.ThrowStatement:
case SyntaxKind.ReturnStatement:
case SyntaxKind.SwitchStatement:
case SyntaxKind.BreakStatement:
case SyntaxKind.ContinueStatement:
case SyntaxKind.ForInStatement:
case SyntaxKind.ForStatement:
case SyntaxKind.WhileStatement:
case SyntaxKind.WithStatement:
case SyntaxKind.EmptyStatement:
case SyntaxKind.TryStatement:
case SyntaxKind.LabeledStatement:
case SyntaxKind.DoStatement:
case SyntaxKind.DebuggerStatement:
return true;
}
}
return false;
}
export function getToken(list: ISyntaxToken[], kind: SyntaxKind): ISyntaxToken {
for (var i = 0, n = list.length; i < n; i++) {
var token = list[i];
if (token.kind === kind) {
return token;
}
}
return undefined;
}
export function containsToken(list: ISyntaxToken[], kind: SyntaxKind): boolean {
return !!SyntaxUtilities.getToken(list, kind);
}
}
}

View file

@ -1,202 +0,0 @@
///<reference path='references.ts' />
module TypeScript {
export function visitNodeOrToken(visitor: ISyntaxVisitor, element: ISyntaxNodeOrToken): any {
if (element === undefined) { return undefined; }
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);
case SyntaxKind.FunctionType: return visitor.visitFunctionType(<FunctionTypeSyntax>element);
case SyntaxKind.ArrayType: return visitor.visitArrayType(<ArrayTypeSyntax>element);
case SyntaxKind.ConstructorType: return visitor.visitConstructorType(<ConstructorTypeSyntax>element);
case SyntaxKind.GenericType: return visitor.visitGenericType(<GenericTypeSyntax>element);
case SyntaxKind.TypeQuery: return visitor.visitTypeQuery(<TypeQuerySyntax>element);
case SyntaxKind.TupleType: return visitor.visitTupleType(<TupleTypeSyntax>element);
case SyntaxKind.UnionType: return visitor.visitUnionType(<UnionTypeSyntax>element);
case SyntaxKind.ParenthesizedType: return visitor.visitParenthesizedType(<ParenthesizedTypeSyntax>element);
case SyntaxKind.InterfaceDeclaration: return visitor.visitInterfaceDeclaration(<InterfaceDeclarationSyntax>element);
case SyntaxKind.FunctionDeclaration: return visitor.visitFunctionDeclaration(<FunctionDeclarationSyntax>element);
case SyntaxKind.ModuleDeclaration: return visitor.visitModuleDeclaration(<ModuleDeclarationSyntax>element);
case SyntaxKind.ClassDeclaration: return visitor.visitClassDeclaration(<ClassDeclarationSyntax>element);
case SyntaxKind.EnumDeclaration: return visitor.visitEnumDeclaration(<EnumDeclarationSyntax>element);
case SyntaxKind.ImportDeclaration: return visitor.visitImportDeclaration(<ImportDeclarationSyntax>element);
case SyntaxKind.ExportAssignment: return visitor.visitExportAssignment(<ExportAssignmentSyntax>element);
case SyntaxKind.MethodDeclaration: return visitor.visitMethodDeclaration(<MethodDeclarationSyntax>element);
case SyntaxKind.PropertyDeclaration: return visitor.visitPropertyDeclaration(<PropertyDeclarationSyntax>element);
case SyntaxKind.ConstructorDeclaration: return visitor.visitConstructorDeclaration(<ConstructorDeclarationSyntax>element);
case SyntaxKind.GetAccessor: return visitor.visitGetAccessor(<GetAccessorSyntax>element);
case SyntaxKind.SetAccessor: return visitor.visitSetAccessor(<SetAccessorSyntax>element);
case SyntaxKind.PropertySignature: return visitor.visitPropertySignature(<PropertySignatureSyntax>element);
case SyntaxKind.CallSignature: return visitor.visitCallSignature(<CallSignatureSyntax>element);
case SyntaxKind.ConstructSignature: return visitor.visitConstructSignature(<ConstructSignatureSyntax>element);
case SyntaxKind.IndexSignature: return visitor.visitIndexSignature(<IndexSignatureSyntax>element);
case SyntaxKind.MethodSignature: return visitor.visitMethodSignature(<MethodSignatureSyntax>element);
case SyntaxKind.Block: return visitor.visitBlock(<BlockSyntax>element);
case SyntaxKind.IfStatement: return visitor.visitIfStatement(<IfStatementSyntax>element);
case SyntaxKind.VariableStatement: return visitor.visitVariableStatement(<VariableStatementSyntax>element);
case SyntaxKind.ExpressionStatement: return visitor.visitExpressionStatement(<ExpressionStatementSyntax>element);
case SyntaxKind.ReturnStatement: return visitor.visitReturnStatement(<ReturnStatementSyntax>element);
case SyntaxKind.SwitchStatement: return visitor.visitSwitchStatement(<SwitchStatementSyntax>element);
case SyntaxKind.BreakStatement: return visitor.visitBreakStatement(<BreakStatementSyntax>element);
case SyntaxKind.ContinueStatement: return visitor.visitContinueStatement(<ContinueStatementSyntax>element);
case SyntaxKind.ForStatement: return visitor.visitForStatement(<ForStatementSyntax>element);
case SyntaxKind.ForInStatement: return visitor.visitForInStatement(<ForInStatementSyntax>element);
case SyntaxKind.EmptyStatement: return visitor.visitEmptyStatement(<EmptyStatementSyntax>element);
case SyntaxKind.ThrowStatement: return visitor.visitThrowStatement(<ThrowStatementSyntax>element);
case SyntaxKind.WhileStatement: return visitor.visitWhileStatement(<WhileStatementSyntax>element);
case SyntaxKind.TryStatement: return visitor.visitTryStatement(<TryStatementSyntax>element);
case SyntaxKind.LabeledStatement: return visitor.visitLabeledStatement(<LabeledStatementSyntax>element);
case SyntaxKind.DoStatement: return visitor.visitDoStatement(<DoStatementSyntax>element);
case SyntaxKind.DebuggerStatement: return visitor.visitDebuggerStatement(<DebuggerStatementSyntax>element);
case SyntaxKind.WithStatement: return visitor.visitWithStatement(<WithStatementSyntax>element);
case SyntaxKind.PrefixUnaryExpression: return visitor.visitPrefixUnaryExpression(<PrefixUnaryExpressionSyntax>element);
case SyntaxKind.DeleteExpression: return visitor.visitDeleteExpression(<DeleteExpressionSyntax>element);
case SyntaxKind.TypeOfExpression: return visitor.visitTypeOfExpression(<TypeOfExpressionSyntax>element);
case SyntaxKind.VoidExpression: return visitor.visitVoidExpression(<VoidExpressionSyntax>element);
case SyntaxKind.ConditionalExpression: return visitor.visitConditionalExpression(<ConditionalExpressionSyntax>element);
case SyntaxKind.BinaryExpression: return visitor.visitBinaryExpression(<BinaryExpressionSyntax>element);
case SyntaxKind.PostfixUnaryExpression: return visitor.visitPostfixUnaryExpression(<PostfixUnaryExpressionSyntax>element);
case SyntaxKind.PropertyAccessExpression: return visitor.visitPropertyAccessExpression(<PropertyAccessExpressionSyntax>element);
case SyntaxKind.InvocationExpression: return visitor.visitInvocationExpression(<InvocationExpressionSyntax>element);
case SyntaxKind.ArrayLiteralExpression: return visitor.visitArrayLiteralExpression(<ArrayLiteralExpressionSyntax>element);
case SyntaxKind.ObjectLiteralExpression: return visitor.visitObjectLiteralExpression(<ObjectLiteralExpressionSyntax>element);
case SyntaxKind.ObjectCreationExpression: return visitor.visitObjectCreationExpression(<ObjectCreationExpressionSyntax>element);
case SyntaxKind.ParenthesizedExpression: return visitor.visitParenthesizedExpression(<ParenthesizedExpressionSyntax>element);
case SyntaxKind.ParenthesizedArrowFunctionExpression: return visitor.visitParenthesizedArrowFunctionExpression(<ParenthesizedArrowFunctionExpressionSyntax>element);
case SyntaxKind.SimpleArrowFunctionExpression: return visitor.visitSimpleArrowFunctionExpression(<SimpleArrowFunctionExpressionSyntax>element);
case SyntaxKind.TypeAssertionExpression: return visitor.visitTypeAssertionExpression(<TypeAssertionExpressionSyntax>element);
case SyntaxKind.ElementAccessExpression: return visitor.visitElementAccessExpression(<ElementAccessExpressionSyntax>element);
case SyntaxKind.FunctionExpression: return visitor.visitFunctionExpression(<FunctionExpressionSyntax>element);
case SyntaxKind.OmittedExpression: return visitor.visitOmittedExpression(<OmittedExpressionSyntax>element);
case SyntaxKind.TemplateExpression: return visitor.visitTemplateExpression(<TemplateExpressionSyntax>element);
case SyntaxKind.TemplateAccessExpression: return visitor.visitTemplateAccessExpression(<TemplateAccessExpressionSyntax>element);
case SyntaxKind.YieldExpression: return visitor.visitYieldExpression(<YieldExpressionSyntax>element);
case SyntaxKind.AwaitExpression: return visitor.visitAwaitExpression(<AwaitExpressionSyntax>element);
case SyntaxKind.VariableDeclaration: return visitor.visitVariableDeclaration(<VariableDeclarationSyntax>element);
case SyntaxKind.VariableDeclarator: return visitor.visitVariableDeclarator(<VariableDeclaratorSyntax>element);
case SyntaxKind.ArgumentList: return visitor.visitArgumentList(<ArgumentListSyntax>element);
case SyntaxKind.ParameterList: return visitor.visitParameterList(<ParameterListSyntax>element);
case SyntaxKind.TypeArgumentList: return visitor.visitTypeArgumentList(<TypeArgumentListSyntax>element);
case SyntaxKind.TypeParameterList: return visitor.visitTypeParameterList(<TypeParameterListSyntax>element);
case SyntaxKind.HeritageClause: return visitor.visitHeritageClause(<HeritageClauseSyntax>element);
case SyntaxKind.EqualsValueClause: return visitor.visitEqualsValueClause(<EqualsValueClauseSyntax>element);
case SyntaxKind.CaseSwitchClause: return visitor.visitCaseSwitchClause(<CaseSwitchClauseSyntax>element);
case SyntaxKind.DefaultSwitchClause: return visitor.visitDefaultSwitchClause(<DefaultSwitchClauseSyntax>element);
case SyntaxKind.ElseClause: return visitor.visitElseClause(<ElseClauseSyntax>element);
case SyntaxKind.CatchClause: return visitor.visitCatchClause(<CatchClauseSyntax>element);
case SyntaxKind.FinallyClause: return visitor.visitFinallyClause(<FinallyClauseSyntax>element);
case SyntaxKind.TemplateClause: return visitor.visitTemplateClause(<TemplateClauseSyntax>element);
case SyntaxKind.TypeParameter: return visitor.visitTypeParameter(<TypeParameterSyntax>element);
case SyntaxKind.Constraint: return visitor.visitConstraint(<ConstraintSyntax>element);
case SyntaxKind.Parameter: return visitor.visitParameter(<ParameterSyntax>element);
case SyntaxKind.EnumElement: return visitor.visitEnumElement(<EnumElementSyntax>element);
case SyntaxKind.TypeAnnotation: return visitor.visitTypeAnnotation(<TypeAnnotationSyntax>element);
case SyntaxKind.ExpressionBody: return visitor.visitExpressionBody(<ExpressionBody>element);
case SyntaxKind.ComputedPropertyName: return visitor.visitComputedPropertyName(<ComputedPropertyNameSyntax>element);
case SyntaxKind.PropertyAssignment: return visitor.visitPropertyAssignment(<PropertyAssignmentSyntax>element);
case SyntaxKind.TypeAlias: return visitor.visitTypeAlias(<TypeAliasSyntax>element);
case SyntaxKind.ExternalModuleReference: return visitor.visitExternalModuleReference(<ExternalModuleReferenceSyntax>element);
case SyntaxKind.ModuleNameModuleReference: return visitor.visitModuleNameModuleReference(<ModuleNameModuleReferenceSyntax>element);
default: return visitor.visitToken(<ISyntaxToken>element);
}
}
export interface ISyntaxVisitor {
visitToken(token: ISyntaxToken): any;
visitSourceUnit(node: SourceUnitSyntax): any;
visitQualifiedName(node: QualifiedNameSyntax): any;
visitObjectType(node: ObjectTypeSyntax): any;
visitFunctionType(node: FunctionTypeSyntax): any;
visitArrayType(node: ArrayTypeSyntax): any;
visitConstructorType(node: ConstructorTypeSyntax): any;
visitGenericType(node: GenericTypeSyntax): any;
visitTypeQuery(node: TypeQuerySyntax): any;
visitTupleType(node: TupleTypeSyntax): any;
visitUnionType(node: UnionTypeSyntax): any;
visitParenthesizedType(node: ParenthesizedTypeSyntax): any;
visitInterfaceDeclaration(node: InterfaceDeclarationSyntax): any;
visitFunctionDeclaration(node: FunctionDeclarationSyntax): any;
visitModuleDeclaration(node: ModuleDeclarationSyntax): any;
visitClassDeclaration(node: ClassDeclarationSyntax): any;
visitEnumDeclaration(node: EnumDeclarationSyntax): any;
visitImportDeclaration(node: ImportDeclarationSyntax): any;
visitExportAssignment(node: ExportAssignmentSyntax): any;
visitMethodDeclaration(node: MethodDeclarationSyntax): any;
visitPropertyDeclaration(node: PropertyDeclarationSyntax): any;
visitConstructorDeclaration(node: ConstructorDeclarationSyntax): any;
visitGetAccessor(node: GetAccessorSyntax): any;
visitSetAccessor(node: SetAccessorSyntax): any;
visitPropertySignature(node: PropertySignatureSyntax): any;
visitCallSignature(node: CallSignatureSyntax): any;
visitConstructSignature(node: ConstructSignatureSyntax): any;
visitIndexSignature(node: IndexSignatureSyntax): any;
visitMethodSignature(node: MethodSignatureSyntax): any;
visitBlock(node: BlockSyntax): any;
visitIfStatement(node: IfStatementSyntax): any;
visitVariableStatement(node: VariableStatementSyntax): any;
visitExpressionStatement(node: ExpressionStatementSyntax): any;
visitReturnStatement(node: ReturnStatementSyntax): any;
visitSwitchStatement(node: SwitchStatementSyntax): any;
visitBreakStatement(node: BreakStatementSyntax): any;
visitContinueStatement(node: ContinueStatementSyntax): any;
visitForStatement(node: ForStatementSyntax): any;
visitForInStatement(node: ForInStatementSyntax): any;
visitEmptyStatement(node: EmptyStatementSyntax): any;
visitThrowStatement(node: ThrowStatementSyntax): any;
visitWhileStatement(node: WhileStatementSyntax): any;
visitTryStatement(node: TryStatementSyntax): any;
visitLabeledStatement(node: LabeledStatementSyntax): any;
visitDoStatement(node: DoStatementSyntax): any;
visitDebuggerStatement(node: DebuggerStatementSyntax): any;
visitWithStatement(node: WithStatementSyntax): any;
visitPrefixUnaryExpression(node: PrefixUnaryExpressionSyntax): any;
visitDeleteExpression(node: DeleteExpressionSyntax): any;
visitTypeOfExpression(node: TypeOfExpressionSyntax): any;
visitVoidExpression(node: VoidExpressionSyntax): any;
visitConditionalExpression(node: ConditionalExpressionSyntax): any;
visitBinaryExpression(node: BinaryExpressionSyntax): any;
visitPostfixUnaryExpression(node: PostfixUnaryExpressionSyntax): any;
visitPropertyAccessExpression(node: PropertyAccessExpressionSyntax): any;
visitInvocationExpression(node: InvocationExpressionSyntax): any;
visitArrayLiteralExpression(node: ArrayLiteralExpressionSyntax): any;
visitObjectLiteralExpression(node: ObjectLiteralExpressionSyntax): any;
visitObjectCreationExpression(node: ObjectCreationExpressionSyntax): any;
visitParenthesizedExpression(node: ParenthesizedExpressionSyntax): any;
visitParenthesizedArrowFunctionExpression(node: ParenthesizedArrowFunctionExpressionSyntax): any;
visitSimpleArrowFunctionExpression(node: SimpleArrowFunctionExpressionSyntax): any;
visitTypeAssertionExpression(node: TypeAssertionExpressionSyntax): any;
visitElementAccessExpression(node: ElementAccessExpressionSyntax): any;
visitFunctionExpression(node: FunctionExpressionSyntax): any;
visitOmittedExpression(node: OmittedExpressionSyntax): any;
visitTemplateExpression(node: TemplateExpressionSyntax): any;
visitTemplateAccessExpression(node: TemplateAccessExpressionSyntax): any;
visitYieldExpression(node: YieldExpressionSyntax): any;
visitAwaitExpression(node: AwaitExpressionSyntax): any;
visitVariableDeclaration(node: VariableDeclarationSyntax): any;
visitVariableDeclarator(node: VariableDeclaratorSyntax): any;
visitArgumentList(node: ArgumentListSyntax): any;
visitParameterList(node: ParameterListSyntax): any;
visitTypeArgumentList(node: TypeArgumentListSyntax): any;
visitTypeParameterList(node: TypeParameterListSyntax): any;
visitHeritageClause(node: HeritageClauseSyntax): any;
visitEqualsValueClause(node: EqualsValueClauseSyntax): any;
visitCaseSwitchClause(node: CaseSwitchClauseSyntax): any;
visitDefaultSwitchClause(node: DefaultSwitchClauseSyntax): any;
visitElseClause(node: ElseClauseSyntax): any;
visitCatchClause(node: CatchClauseSyntax): any;
visitFinallyClause(node: FinallyClauseSyntax): any;
visitTemplateClause(node: TemplateClauseSyntax): any;
visitTypeParameter(node: TypeParameterSyntax): any;
visitConstraint(node: ConstraintSyntax): any;
visitParameter(node: ParameterSyntax): any;
visitEnumElement(node: EnumElementSyntax): any;
visitTypeAnnotation(node: TypeAnnotationSyntax): any;
visitExpressionBody(node: ExpressionBody): any;
visitComputedPropertyName(node: ComputedPropertyNameSyntax): any;
visitPropertyAssignment(node: PropertyAssignmentSyntax): any;
visitTypeAlias(node: TypeAliasSyntax): any;
visitExternalModuleReference(node: ExternalModuleReferenceSyntax): any;
visitModuleNameModuleReference(node: ModuleNameModuleReferenceSyntax): any;
}
}

View file

@ -1,638 +0,0 @@
///<reference path='references.ts' />
module TypeScript {
export class SyntaxWalker implements ISyntaxVisitor {
public visitToken(token: ISyntaxToken): void {
}
private visitOptionalToken(token: ISyntaxToken): void {
if (token === undefined) {
return;
}
this.visitToken(token);
}
public visitList(list: ISyntaxNodeOrToken[]): void {
for (var i = 0, n = list.length; i < n; i++) {
visitNodeOrToken(this, list[i]);
}
}
public visitSourceUnit(node: SourceUnitSyntax): void {
this.visitList(node.moduleElements);
this.visitToken(node.endOfFileToken);
}
public visitQualifiedName(node: QualifiedNameSyntax): void {
visitNodeOrToken(this, node.left);
this.visitToken(node.dotToken);
this.visitToken(node.right);
}
public visitObjectType(node: ObjectTypeSyntax): void {
this.visitToken(node.openBraceToken);
this.visitList(node.typeMembers);
this.visitToken(node.closeBraceToken);
}
public visitFunctionType(node: FunctionTypeSyntax): void {
visitNodeOrToken(this, node.typeParameterList);
visitNodeOrToken(this, node.parameterList);
this.visitToken(node.equalsGreaterThanToken);
visitNodeOrToken(this, node.type);
}
public visitArrayType(node: ArrayTypeSyntax): void {
visitNodeOrToken(this, node.type);
this.visitToken(node.openBracketToken);
this.visitToken(node.closeBracketToken);
}
public visitConstructorType(node: ConstructorTypeSyntax): void {
this.visitToken(node.newKeyword);
visitNodeOrToken(this, node.typeParameterList);
visitNodeOrToken(this, node.parameterList);
this.visitToken(node.equalsGreaterThanToken);
visitNodeOrToken(this, node.type);
}
public visitGenericType(node: GenericTypeSyntax): void {
visitNodeOrToken(this, node.name);
visitNodeOrToken(this, node.typeArgumentList);
}
public visitTypeQuery(node: TypeQuerySyntax): void {
this.visitToken(node.typeOfKeyword);
visitNodeOrToken(this, node.name);
}
public visitTupleType(node: TupleTypeSyntax): void {
this.visitToken(node.openBracketToken);
this.visitList(node.types);
this.visitToken(node.closeBracketToken);
}
public visitUnionType(node: UnionTypeSyntax): void {
visitNodeOrToken(this, node.left);
this.visitToken(node.barToken);
visitNodeOrToken(this, node.right);
}
public visitParenthesizedType(node: ParenthesizedTypeSyntax): void {
this.visitToken(node.openParenToken);
visitNodeOrToken(this, node.type);
this.visitToken(node.closeParenToken);
}
public visitInterfaceDeclaration(node: InterfaceDeclarationSyntax): void {
this.visitList(node.modifiers);
this.visitToken(node.interfaceKeyword);
this.visitToken(node.identifier);
visitNodeOrToken(this, node.typeParameterList);
this.visitList(node.heritageClauses);
visitNodeOrToken(this, node.body);
}
public visitFunctionDeclaration(node: FunctionDeclarationSyntax): void {
this.visitList(node.modifiers);
this.visitToken(node.functionKeyword);
this.visitOptionalToken(node.asterixToken);
this.visitToken(node.identifier);
visitNodeOrToken(this, node.callSignature);
visitNodeOrToken(this, node.body);
}
public visitModuleDeclaration(node: ModuleDeclarationSyntax): void {
this.visitList(node.modifiers);
this.visitToken(node.moduleKeyword);
visitNodeOrToken(this, node.name);
this.visitToken(node.openBraceToken);
this.visitList(node.moduleElements);
this.visitToken(node.closeBraceToken);
}
public visitClassDeclaration(node: ClassDeclarationSyntax): void {
this.visitList(node.modifiers);
this.visitToken(node.classKeyword);
this.visitToken(node.identifier);
visitNodeOrToken(this, node.typeParameterList);
this.visitList(node.heritageClauses);
this.visitToken(node.openBraceToken);
this.visitList(node.classElements);
this.visitToken(node.closeBraceToken);
}
public visitEnumDeclaration(node: EnumDeclarationSyntax): void {
this.visitList(node.modifiers);
this.visitToken(node.enumKeyword);
this.visitToken(node.identifier);
this.visitToken(node.openBraceToken);
this.visitList(node.enumElements);
this.visitToken(node.closeBraceToken);
}
public visitImportDeclaration(node: ImportDeclarationSyntax): void {
this.visitList(node.modifiers);
this.visitToken(node.importKeyword);
this.visitToken(node.identifier);
this.visitToken(node.equalsToken);
visitNodeOrToken(this, node.moduleReference);
this.visitOptionalToken(node.semicolonToken);
}
public visitExportAssignment(node: ExportAssignmentSyntax): void {
this.visitList(node.modifiers);
this.visitToken(node.exportKeyword);
this.visitToken(node.equalsToken);
this.visitToken(node.identifier);
this.visitOptionalToken(node.semicolonToken);
}
public visitMethodDeclaration(node: MethodDeclarationSyntax): void {
this.visitList(node.modifiers);
this.visitOptionalToken(node.asterixToken);
visitNodeOrToken(this, node.propertyName);
visitNodeOrToken(this, node.callSignature);
visitNodeOrToken(this, node.body);
}
public visitPropertyDeclaration(node: PropertyDeclarationSyntax): void {
this.visitList(node.modifiers);
visitNodeOrToken(this, node.variableDeclarator);
this.visitOptionalToken(node.semicolonToken);
}
public visitConstructorDeclaration(node: ConstructorDeclarationSyntax): void {
this.visitList(node.modifiers);
this.visitToken(node.constructorKeyword);
visitNodeOrToken(this, node.callSignature);
visitNodeOrToken(this, node.body);
}
public visitGetAccessor(node: GetAccessorSyntax): void {
this.visitList(node.modifiers);
this.visitToken(node.getKeyword);
visitNodeOrToken(this, node.propertyName);
visitNodeOrToken(this, node.callSignature);
visitNodeOrToken(this, node.body);
}
public visitSetAccessor(node: SetAccessorSyntax): void {
this.visitList(node.modifiers);
this.visitToken(node.setKeyword);
visitNodeOrToken(this, node.propertyName);
visitNodeOrToken(this, node.callSignature);
visitNodeOrToken(this, node.body);
}
public visitPropertySignature(node: PropertySignatureSyntax): void {
visitNodeOrToken(this, node.propertyName);
this.visitOptionalToken(node.questionToken);
visitNodeOrToken(this, node.typeAnnotation);
this.visitOptionalToken(node.semicolonOrCommaToken);
}
public visitCallSignature(node: CallSignatureSyntax): void {
visitNodeOrToken(this, node.typeParameterList);
visitNodeOrToken(this, node.parameterList);
visitNodeOrToken(this, node.typeAnnotation);
this.visitOptionalToken(node.semicolonOrCommaToken);
}
public visitConstructSignature(node: ConstructSignatureSyntax): void {
this.visitToken(node.newKeyword);
visitNodeOrToken(this, node.callSignature);
}
public visitIndexSignature(node: IndexSignatureSyntax): void {
this.visitList(node.modifiers);
this.visitToken(node.openBracketToken);
this.visitList(node.parameters);
this.visitToken(node.closeBracketToken);
visitNodeOrToken(this, node.typeAnnotation);
this.visitOptionalToken(node.semicolonOrCommaToken);
}
public visitMethodSignature(node: MethodSignatureSyntax): void {
visitNodeOrToken(this, node.propertyName);
this.visitOptionalToken(node.questionToken);
visitNodeOrToken(this, node.callSignature);
}
public visitBlock(node: BlockSyntax): void {
this.visitOptionalToken(node.equalsGreaterThanToken);
this.visitToken(node.openBraceToken);
this.visitList(node.statements);
this.visitToken(node.closeBraceToken);
}
public visitIfStatement(node: IfStatementSyntax): void {
this.visitToken(node.ifKeyword);
this.visitToken(node.openParenToken);
visitNodeOrToken(this, node.condition);
this.visitToken(node.closeParenToken);
visitNodeOrToken(this, node.statement);
visitNodeOrToken(this, node.elseClause);
}
public visitVariableStatement(node: VariableStatementSyntax): void {
this.visitList(node.modifiers);
visitNodeOrToken(this, node.variableDeclaration);
this.visitOptionalToken(node.semicolonToken);
}
public visitExpressionStatement(node: ExpressionStatementSyntax): void {
visitNodeOrToken(this, node.expression);
this.visitOptionalToken(node.semicolonToken);
}
public visitReturnStatement(node: ReturnStatementSyntax): void {
this.visitToken(node.returnKeyword);
visitNodeOrToken(this, node.expression);
this.visitOptionalToken(node.semicolonToken);
}
public visitSwitchStatement(node: SwitchStatementSyntax): void {
this.visitToken(node.switchKeyword);
this.visitToken(node.openParenToken);
visitNodeOrToken(this, node.expression);
this.visitToken(node.closeParenToken);
this.visitToken(node.openBraceToken);
this.visitList(node.switchClauses);
this.visitToken(node.closeBraceToken);
}
public visitBreakStatement(node: BreakStatementSyntax): void {
this.visitToken(node.breakKeyword);
this.visitOptionalToken(node.identifier);
this.visitOptionalToken(node.semicolonToken);
}
public visitContinueStatement(node: ContinueStatementSyntax): void {
this.visitToken(node.continueKeyword);
this.visitOptionalToken(node.identifier);
this.visitOptionalToken(node.semicolonToken);
}
public visitForStatement(node: ForStatementSyntax): void {
this.visitToken(node.forKeyword);
this.visitToken(node.openParenToken);
visitNodeOrToken(this, node.initializer);
this.visitToken(node.firstSemicolonToken);
visitNodeOrToken(this, node.condition);
this.visitToken(node.secondSemicolonToken);
visitNodeOrToken(this, node.incrementor);
this.visitToken(node.closeParenToken);
visitNodeOrToken(this, node.statement);
}
public visitForInStatement(node: ForInStatementSyntax): void {
this.visitToken(node.forKeyword);
this.visitToken(node.openParenToken);
visitNodeOrToken(this, node.left);
this.visitToken(node.inKeyword);
visitNodeOrToken(this, node.right);
this.visitToken(node.closeParenToken);
visitNodeOrToken(this, node.statement);
}
public visitEmptyStatement(node: EmptyStatementSyntax): void {
this.visitToken(node.semicolonToken);
}
public visitThrowStatement(node: ThrowStatementSyntax): void {
this.visitToken(node.throwKeyword);
visitNodeOrToken(this, node.expression);
this.visitOptionalToken(node.semicolonToken);
}
public visitWhileStatement(node: WhileStatementSyntax): void {
this.visitToken(node.whileKeyword);
this.visitToken(node.openParenToken);
visitNodeOrToken(this, node.condition);
this.visitToken(node.closeParenToken);
visitNodeOrToken(this, node.statement);
}
public visitTryStatement(node: TryStatementSyntax): void {
this.visitToken(node.tryKeyword);
visitNodeOrToken(this, node.block);
visitNodeOrToken(this, node.catchClause);
visitNodeOrToken(this, node.finallyClause);
}
public visitLabeledStatement(node: LabeledStatementSyntax): void {
this.visitToken(node.identifier);
this.visitToken(node.colonToken);
visitNodeOrToken(this, node.statement);
}
public visitDoStatement(node: DoStatementSyntax): void {
this.visitToken(node.doKeyword);
visitNodeOrToken(this, node.statement);
this.visitToken(node.whileKeyword);
this.visitToken(node.openParenToken);
visitNodeOrToken(this, node.condition);
this.visitToken(node.closeParenToken);
this.visitOptionalToken(node.semicolonToken);
}
public visitDebuggerStatement(node: DebuggerStatementSyntax): void {
this.visitToken(node.debuggerKeyword);
this.visitOptionalToken(node.semicolonToken);
}
public visitWithStatement(node: WithStatementSyntax): void {
this.visitToken(node.withKeyword);
this.visitToken(node.openParenToken);
visitNodeOrToken(this, node.condition);
this.visitToken(node.closeParenToken);
visitNodeOrToken(this, node.statement);
}
public visitPrefixUnaryExpression(node: PrefixUnaryExpressionSyntax): void {
this.visitToken(node.operatorToken);
visitNodeOrToken(this, node.operand);
}
public visitDeleteExpression(node: DeleteExpressionSyntax): void {
this.visitToken(node.deleteKeyword);
visitNodeOrToken(this, node.expression);
}
public visitTypeOfExpression(node: TypeOfExpressionSyntax): void {
this.visitToken(node.typeOfKeyword);
visitNodeOrToken(this, node.expression);
}
public visitVoidExpression(node: VoidExpressionSyntax): void {
this.visitToken(node.voidKeyword);
visitNodeOrToken(this, node.expression);
}
public visitConditionalExpression(node: ConditionalExpressionSyntax): void {
visitNodeOrToken(this, node.condition);
this.visitToken(node.questionToken);
visitNodeOrToken(this, node.whenTrue);
this.visitToken(node.colonToken);
visitNodeOrToken(this, node.whenFalse);
}
public visitBinaryExpression(node: BinaryExpressionSyntax): void {
visitNodeOrToken(this, node.left);
this.visitToken(node.operatorToken);
visitNodeOrToken(this, node.right);
}
public visitPostfixUnaryExpression(node: PostfixUnaryExpressionSyntax): void {
visitNodeOrToken(this, node.operand);
this.visitToken(node.operatorToken);
}
public visitPropertyAccessExpression(node: PropertyAccessExpressionSyntax): void {
visitNodeOrToken(this, node.expression);
this.visitToken(node.dotToken);
this.visitToken(node.name);
}
public visitInvocationExpression(node: InvocationExpressionSyntax): void {
visitNodeOrToken(this, node.expression);
visitNodeOrToken(this, node.argumentList);
}
public visitArrayLiteralExpression(node: ArrayLiteralExpressionSyntax): void {
this.visitToken(node.openBracketToken);
this.visitList(node.expressions);
this.visitToken(node.closeBracketToken);
}
public visitObjectLiteralExpression(node: ObjectLiteralExpressionSyntax): void {
this.visitToken(node.openBraceToken);
this.visitList(node.propertyAssignments);
this.visitToken(node.closeBraceToken);
}
public visitObjectCreationExpression(node: ObjectCreationExpressionSyntax): void {
this.visitToken(node.newKeyword);
visitNodeOrToken(this, node.expression);
visitNodeOrToken(this, node.argumentList);
}
public visitParenthesizedExpression(node: ParenthesizedExpressionSyntax): void {
this.visitToken(node.openParenToken);
visitNodeOrToken(this, node.expression);
this.visitToken(node.closeParenToken);
}
public visitParenthesizedArrowFunctionExpression(node: ParenthesizedArrowFunctionExpressionSyntax): void {
this.visitOptionalToken(node.asyncKeyword);
visitNodeOrToken(this, node.callSignature);
this.visitOptionalToken(node.equalsGreaterThanToken);
visitNodeOrToken(this, node.body);
}
public visitSimpleArrowFunctionExpression(node: SimpleArrowFunctionExpressionSyntax): void {
this.visitOptionalToken(node.asyncKeyword);
visitNodeOrToken(this, node.parameter);
this.visitToken(node.equalsGreaterThanToken);
visitNodeOrToken(this, node.body);
}
public visitTypeAssertionExpression(node: TypeAssertionExpressionSyntax): void {
this.visitToken(node.lessThanToken);
visitNodeOrToken(this, node.type);
this.visitToken(node.greaterThanToken);
visitNodeOrToken(this, node.expression);
}
public visitElementAccessExpression(node: ElementAccessExpressionSyntax): void {
visitNodeOrToken(this, node.expression);
this.visitToken(node.openBracketToken);
visitNodeOrToken(this, node.argumentExpression);
this.visitToken(node.closeBracketToken);
}
public visitFunctionExpression(node: FunctionExpressionSyntax): void {
this.visitOptionalToken(node.asyncKeyword);
this.visitToken(node.functionKeyword);
this.visitOptionalToken(node.asterixToken);
this.visitOptionalToken(node.identifier);
visitNodeOrToken(this, node.callSignature);
visitNodeOrToken(this, node.body);
}
public visitOmittedExpression(node: OmittedExpressionSyntax): void {
}
public visitTemplateExpression(node: TemplateExpressionSyntax): void {
this.visitToken(node.templateStartToken);
this.visitList(node.templateClauses);
}
public visitTemplateAccessExpression(node: TemplateAccessExpressionSyntax): void {
visitNodeOrToken(this, node.expression);
visitNodeOrToken(this, node.templateExpression);
}
public visitYieldExpression(node: YieldExpressionSyntax): void {
this.visitToken(node.yieldKeyword);
this.visitOptionalToken(node.asterixToken);
visitNodeOrToken(this, node.expression);
}
public visitAwaitExpression(node: AwaitExpressionSyntax): void {
this.visitToken(node.awaitKeyword);
visitNodeOrToken(this, node.expression);
}
public visitVariableDeclaration(node: VariableDeclarationSyntax): void {
this.visitToken(node.varConstOrLetKeyword);
this.visitList(node.variableDeclarators);
}
public visitVariableDeclarator(node: VariableDeclaratorSyntax): void {
visitNodeOrToken(this, node.propertyName);
visitNodeOrToken(this, node.typeAnnotation);
visitNodeOrToken(this, node.equalsValueClause);
}
public visitArgumentList(node: ArgumentListSyntax): void {
visitNodeOrToken(this, node.typeArgumentList);
this.visitToken(node.openParenToken);
this.visitList(node.arguments);
this.visitToken(node.closeParenToken);
}
public visitParameterList(node: ParameterListSyntax): void {
this.visitToken(node.openParenToken);
this.visitList(node.parameters);
this.visitToken(node.closeParenToken);
}
public visitTypeArgumentList(node: TypeArgumentListSyntax): void {
this.visitToken(node.lessThanToken);
this.visitList(node.typeArguments);
this.visitToken(node.greaterThanToken);
}
public visitTypeParameterList(node: TypeParameterListSyntax): void {
this.visitToken(node.lessThanToken);
this.visitList(node.typeParameters);
this.visitToken(node.greaterThanToken);
}
public visitHeritageClause(node: HeritageClauseSyntax): void {
this.visitToken(node.extendsOrImplementsKeyword);
this.visitList(node.typeNames);
}
public visitEqualsValueClause(node: EqualsValueClauseSyntax): void {
this.visitToken(node.equalsToken);
visitNodeOrToken(this, node.value);
}
public visitCaseSwitchClause(node: CaseSwitchClauseSyntax): void {
this.visitToken(node.caseKeyword);
visitNodeOrToken(this, node.expression);
this.visitToken(node.colonToken);
this.visitList(node.statements);
}
public visitDefaultSwitchClause(node: DefaultSwitchClauseSyntax): void {
this.visitToken(node.defaultKeyword);
this.visitToken(node.colonToken);
this.visitList(node.statements);
}
public visitElseClause(node: ElseClauseSyntax): void {
this.visitToken(node.elseKeyword);
visitNodeOrToken(this, node.statement);
}
public visitCatchClause(node: CatchClauseSyntax): void {
this.visitToken(node.catchKeyword);
this.visitToken(node.openParenToken);
this.visitToken(node.identifier);
visitNodeOrToken(this, node.typeAnnotation);
this.visitToken(node.closeParenToken);
visitNodeOrToken(this, node.block);
}
public visitFinallyClause(node: FinallyClauseSyntax): void {
this.visitToken(node.finallyKeyword);
visitNodeOrToken(this, node.block);
}
public visitTemplateClause(node: TemplateClauseSyntax): void {
visitNodeOrToken(this, node.expression);
this.visitToken(node.templateMiddleOrEndToken);
}
public visitTypeParameter(node: TypeParameterSyntax): void {
this.visitToken(node.identifier);
visitNodeOrToken(this, node.constraint);
}
public visitConstraint(node: ConstraintSyntax): void {
this.visitToken(node.extendsKeyword);
visitNodeOrToken(this, node.typeOrExpression);
}
public visitParameter(node: ParameterSyntax): void {
this.visitOptionalToken(node.dotDotDotToken);
this.visitList(node.modifiers);
this.visitToken(node.identifier);
this.visitOptionalToken(node.questionToken);
visitNodeOrToken(this, node.typeAnnotation);
visitNodeOrToken(this, node.equalsValueClause);
}
public visitEnumElement(node: EnumElementSyntax): void {
visitNodeOrToken(this, node.propertyName);
visitNodeOrToken(this, node.equalsValueClause);
}
public visitTypeAnnotation(node: TypeAnnotationSyntax): void {
this.visitToken(node.colonToken);
visitNodeOrToken(this, node.type);
}
public visitExpressionBody(node: ExpressionBody): void {
this.visitToken(node.equalsGreaterThanToken);
visitNodeOrToken(this, node.expression);
}
public visitComputedPropertyName(node: ComputedPropertyNameSyntax): void {
this.visitToken(node.openBracketToken);
visitNodeOrToken(this, node.expression);
this.visitToken(node.closeBracketToken);
}
public visitPropertyAssignment(node: PropertyAssignmentSyntax): void {
visitNodeOrToken(this, node.propertyName);
this.visitToken(node.colonToken);
visitNodeOrToken(this, node.expression);
}
public visitTypeAlias(node: TypeAliasSyntax): void {
this.visitList(node.modifiers);
this.visitToken(node.typeKeyword);
this.visitToken(node.identifier);
this.visitToken(node.equalsToken);
visitNodeOrToken(this, node.type);
this.visitOptionalToken(node.semicolonToken);
}
public visitExternalModuleReference(node: ExternalModuleReferenceSyntax): void {
this.visitToken(node.requireKeyword);
this.visitToken(node.openParenToken);
visitNodeOrToken(this, node.expression);
this.visitToken(node.closeParenToken);
}
public visitModuleNameModuleReference(node: ModuleNameModuleReferenceSyntax): void {
visitNodeOrToken(this, node.moduleName);
}
}
}

View file

@ -1,175 +0,0 @@
module TypeScript {
function assertParent(parent: ISyntaxElement, child: ISyntaxElement) {
if (child) {
return Debug.assert(parent === child.parent);
}
}
export function nodeStructuralEquals(node1: TypeScript.ISyntaxNode, node2: TypeScript.ISyntaxNode, checkParents: boolean, text1: ISimpleText, text2: ISimpleText): boolean {
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);
if (node1.kind !== node2.kind) { return false; }
if (childCount(node1) !== childCount(node2)) { return false; }
for (var i = 0, n = childCount(node1); i < n; i++) {
var element1 = childAt(node1, i);
var element2 = childAt(node2, i);
if (checkParents) {
assertParent(node1, element1);
assertParent(node2, element2);
}
if (!elementStructuralEquals(element1, element2, checkParents, text1, text2)) {
return false;
}
}
return true;
}
export function nodeOrTokenStructuralEquals(node1: TypeScript.ISyntaxNodeOrToken, node2: TypeScript.ISyntaxNodeOrToken, checkParents: boolean, text1: ISimpleText, text2: ISimpleText): boolean {
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);
if (TypeScript.isToken(node1)) {
return TypeScript.isToken(node2) ? tokenStructuralEquals(<TypeScript.ISyntaxToken>node1, <TypeScript.ISyntaxToken>node2, text1, text2) : false;
}
return TypeScript.isNode(node2) ? nodeStructuralEquals(<TypeScript.ISyntaxNode>node1, <TypeScript.ISyntaxNode>node2, checkParents, text1, text2) : false;
}
export function tokenStructuralEquals(token1: TypeScript.ISyntaxToken, token2: TypeScript.ISyntaxToken, text1: ISimpleText, text2: ISimpleText): boolean {
if (token1 === token2) {
return true;
}
if (!token1 || !token2) {
return false;
}
Debug.assert(token1.parent);
Debug.assert(token2.parent);
return token1.kind === token2.kind &&
TypeScript.width(token1) === TypeScript.width(token2) &&
token1.fullWidth() === token2.fullWidth() &&
token1.fullStart() === token2.fullStart() &&
TypeScript.fullEnd(token1) === TypeScript.fullEnd(token2) &&
TypeScript.start(token1, text1) === TypeScript.start(token2, text2) &&
token1.text() === token2.text() &&
triviaListStructuralEquals(token1.leadingTrivia(text1), token2.leadingTrivia(text2));
}
export function triviaListStructuralEquals(triviaList1: TypeScript.ISyntaxTriviaList, triviaList2: TypeScript.ISyntaxTriviaList): boolean {
Debug.assert(triviaList1.isShared() || triviaList1.parent);
Debug.assert(triviaList1.isShared() || triviaList2.parent);
if (triviaList1.count() !== triviaList2.count()) {
return false;
}
for (var i = 0, n = triviaList1.count(); i < n; i++) {
if (!triviaStructuralEquals(triviaList1.syntaxTriviaAt(i), triviaList2.syntaxTriviaAt(i))) {
return false;
}
}
return true;
}
export function triviaStructuralEquals(trivia1: TypeScript.ISyntaxTrivia, trivia2: TypeScript.ISyntaxTrivia): boolean {
Debug.assert(trivia1.parent);
Debug.assert(trivia2.parent);
return trivia1.kind === trivia2.kind &&
trivia1.fullWidth() === trivia2.fullWidth() &&
trivia1.fullText() === trivia2.fullText();
}
function listStructuralEquals<T extends TypeScript.ISyntaxNodeOrToken>(list1: T[], list2: T[], checkParents: boolean, text1: ISimpleText, text2: ISimpleText): boolean {
Debug.assert(list1.parent);
Debug.assert(list2.parent);
if (childCount(list1) !== childCount(list2)) {
return false;
}
for (var i = 0, n = childCount(list1); i < n; i++) {
var child1 = childAt(list1, i);
var child2 = childAt(list2, i);
if (checkParents) {
assertParent(list1, child1);
assertParent(list2, child2);
}
if (!elementStructuralEquals(child1, child2, checkParents, text1, text2)) {
return false;
}
}
return true;
}
export function elementStructuralEquals(element1: TypeScript.ISyntaxElement, element2: TypeScript.ISyntaxElement, checkParents: boolean, text1: ISimpleText, text2: ISimpleText) {
if (element1 === element2) {
return true;
}
if (!element1 || !element2) {
return false;
}
Debug.assert(element1.kind === SyntaxKind.SourceUnit || element1.parent);
Debug.assert(element2.kind === SyntaxKind.SourceUnit || element2.parent);
if (element2.kind !== element2.kind) {
return false;
}
if (TypeScript.fullStart(element1) !== TypeScript.fullStart(element2)) {
return false;
}
if (TypeScript.start(element1) !== TypeScript.start(element2)) {
return false;
}
if (TypeScript.fullEnd(element1) !== TypeScript.fullEnd(element2)) {
return false;
}
if (TypeScript.isToken(element1)) {
return tokenStructuralEquals(<TypeScript.ISyntaxToken>element1, <TypeScript.ISyntaxToken>element2, text1, text2);
}
else if (TypeScript.isNode(element1)) {
return nodeStructuralEquals(<TypeScript.ISyntaxNode>element1, <TypeScript.ISyntaxNode>element2, checkParents, text1, text2);
}
else if (TypeScript.isList(element1)) {
return listStructuralEquals(<TypeScript.ISyntaxNodeOrToken[]>element1, <TypeScript.ISyntaxNodeOrToken[]>element2, checkParents, text1, text2);
}
throw TypeScript.Errors.invalidOperation();
}
export function treeStructuralEquals(tree1: TypeScript.SyntaxTree, tree2: TypeScript.SyntaxTree, checkParents: boolean): boolean {
if (!TypeScript.ArrayUtilities.sequenceEquals(tree1.diagnostics(), tree2.diagnostics(), TypeScript.Diagnostic.equals)) {
return false;
}
return nodeStructuralEquals(tree1.sourceUnit(), tree2.sourceUnit(), checkParents, tree1.text, tree2.text);
}
}

File diff suppressed because one or more lines are too long

View file

@ -1,139 +0,0 @@
///<reference path='references.ts' />
module TypeScript {
export enum CharacterCodes {
nullCharacter = 0,
maxAsciiCharacter = 127,
lineFeed = 10, // \n
carriageReturn = 13, // \r
lineSeparator = 0x2028,
paragraphSeparator = 0x2029,
// REVIEW: do we need to support this? The scanner doesn't, but our IText does. This seems
// like an odd disparity? (Or maybe it's completely fine for them to be different).
nextLine = 0x0085,
// Unicode 3.0 space characters
space = 0x0020, // " "
nonBreakingSpace = 0x00A0, //
enQuad = 0x2000,
emQuad = 0x2001,
enSpace = 0x2002,
emSpace = 0x2003,
threePerEmSpace = 0x2004,
fourPerEmSpace = 0x2005,
sixPerEmSpace = 0x2006,
figureSpace = 0x2007,
punctuationSpace = 0x2008,
thinSpace = 0x2009,
hairSpace = 0x200A,
zeroWidthSpace = 0x200B,
narrowNoBreakSpace = 0x202F,
ideographicSpace = 0x3000,
_ = 95,
$ = 36,
_0 = 48,
_1 = 49,
_2 = 50,
_3 = 51,
_4 = 52,
_5 = 53,
_6 = 54,
_7 = 55,
_8 = 56,
_9 = 57,
a = 97,
b = 98,
c = 99,
d = 100,
e = 101,
f = 102,
g = 103,
h = 104,
i = 105,
j = 106,
k = 107,
l = 108,
m = 109,
n = 110,
o = 111,
p = 112,
q = 113,
r = 114,
s = 115,
t = 116,
u = 117,
v = 118,
w = 119,
x = 120,
y = 121,
z = 122,
A = 65,
B = 66,
C = 67,
D = 68,
E = 69,
F = 70,
G = 71,
H = 72,
I = 73,
J = 74,
K = 75,
L = 76,
M = 77,
N = 78,
O = 79,
P = 80,
Q = 81,
R = 82,
S = 83,
T = 84,
U = 85,
V = 86,
W = 87,
X = 88,
Y = 89,
Z = 90,
ampersand = 38, // &
asterisk = 42, // *
at = 64, // @
backslash = 92, // \
backtick = 96, // `
bar = 124, // |
caret = 94, // ^
closeBrace = 125, // }
closeBracket = 93, // ]
closeParen = 41, // )
colon = 58, // :
comma = 44, // ,
dot = 46, // .
doubleQuote = 34, // "
equals = 61, // =
exclamation = 33, // !
greaterThan = 62, // >
lessThan = 60, // <
minus = 45, // -
openBrace = 123, // {
openBracket = 91, // [
openParen = 40, // (
percent = 37, // %
plus = 43, // +
question = 63, // ?
semicolon = 59, // ;
singleQuote = 39, // '
slash = 47, // /
tilde = 126, // ~
backspace = 8, // \b
formFeed = 12, // \f
byteOrderMark = 0xFEFF,
tab = 9, // \t
verticalTab = 11, // \v
}
}

View file

@ -1,17 +0,0 @@
///<reference path='references.ts' />
module TypeScript {
export module LineMap1 {
export function fromSimpleText(text: ISimpleText): LineMap {
return new LineMap(() => TextUtilities.parseLineStarts({ charCodeAt: index => text.charCodeAt(index), length: text.length() }), text.length());
}
export function fromScriptSnapshot(scriptSnapshot: IScriptSnapshot): LineMap {
return new LineMap(() => scriptSnapshot.getLineStartPositions(), scriptSnapshot.getLength());
}
export function fromString(text: string): LineMap {
return new LineMap(() => TextUtilities.parseLineStarts(text), text.length);
}
}
}

View file

@ -1,12 +0,0 @@
///<reference path='..\core\references.ts' />
///<reference path='characterCodes.ts' />
///<reference path='scriptSnapshot.ts' />
///<reference path='text.ts' />
///<reference path='lineMap.ts' />
///<reference path='textFactory.ts' />
///<reference path='textUtilities.ts' />
///<reference path='textSpan.ts' />
// TextChangeRange depends on TextSpan.
///<reference path='textChangeRange.ts' />

View file

@ -1,65 +0,0 @@
///<reference path='references.ts' />
module TypeScript {
/**
* Represents an immutable snapshot of a script at a specified time.Once acquired, the
* snapshot is observably immutable. i.e. the same calls with the same parameters will return
* the same values.
*/
export interface IScriptSnapshot {
/** Gets a portion of the script snapshot specified by [start, end). */
getText(start: number, end: number): string;
/** Gets the length of this script snapshot. */
getLength(): number;
/**
* This call returns the array containing the start position of every line.
* i.e."[0, 10, 55]". TODO: consider making this optional. The language service could
* always determine this (albeit in a more expensive manner).
*/
getLineStartPositions(): number[];
/**
* Gets the TextChangeRange that describe how the text changed between this text and
* an older version. This information is used by the incremental parser to determine
* what sections of the script need to be re-parsed. 'undefined' can be returned if the
* change range cannot be determined. However, in that case, incremental parsing will
* not happen and the entire document will be re - parsed.
*/
getChangeRange(oldSnapshot: IScriptSnapshot): TextChangeRange;
}
export module ScriptSnapshot {
class StringScriptSnapshot implements IScriptSnapshot {
private _lineStartPositions: number[] = undefined;
constructor(private text: string) {
}
public getText(start: number, end: number): string {
return this.text.substring(start, end);
}
public getLength(): number {
return this.text.length;
}
public getLineStartPositions(): number[]{
if (!this._lineStartPositions) {
this._lineStartPositions = TextUtilities.parseLineStarts(this.text);
}
return this._lineStartPositions;
}
public getChangeRange(oldSnapshot: IScriptSnapshot): TextChangeRange {
throw Errors.notYetImplemented();
}
}
export function fromString(text: string): IScriptSnapshot {
return new StringScriptSnapshot(text);
}
}
}

View file

@ -1,21 +0,0 @@
///<reference path='references.ts' />
/**
* Represents an immutable snapshot of text.
*/
module TypeScript {
/**
* Represents an immutable snapshot of text.
*/
export interface ISimpleText {
/**
* Total number of characters in the text source.
*/
length(): number;
substr(start: number, length: number): string;
charCodeAt(index: number): number;
lineMap(): LineMap;
}
}

View file

@ -1,168 +0,0 @@
///<reference path='references.ts' />
module TypeScript {
export class TextChangeRange {
public static unchanged = new TextChangeRange(new TextSpan(0, 0), 0);
private _span: TextSpan;
private _newLength: number;
/**
* Initializes a new instance of TextChangeRange.
*/
constructor(span: TextSpan, newLength: number) {
if (newLength < 0) {
throw Errors.argumentOutOfRange("newLength");
}
this._span = span;
this._newLength = newLength;
}
/**
* The span of text before the edit which is being changed
*/
public span(): TextSpan {
return this._span;
}
/**
* Width of the span after the edit. A 0 here would represent a delete
*/
public newLength(): number {
return this._newLength;
}
public newSpan(): TextSpan {
return new TextSpan(this.span().start(), this.newLength());
}
public isUnchanged(): boolean {
return this.span().isEmpty() && this.newLength() === 0;
}
/**
* Called to merge all the changes that occurred across several versions of a script snapshot
* into a single change. i.e. if a user keeps making successive edits to a script we will
* have a text change from V1 to V2, V2 to V3, ..., Vn.
*
* This function will then merge those changes into a single change range valid between V1 and
* Vn.
*/
public static collapseChangesAcrossMultipleVersions(changes: TextChangeRange[]): TextChangeRange {
if (changes.length === 0) {
return TextChangeRange.unchanged;
}
if (changes.length === 1) {
return changes[0];
}
// We change from talking about { { oldStart, oldLength }, newLength } to { oldStart, oldEnd, newEnd }
// as it makes things much easier to reason about.
var change0 = changes[0];
var oldStartN = change0.span().start();
var oldEndN = change0.span().end();
var newEndN = oldStartN + change0.newLength();
for (var i = 1; i < changes.length; i++) {
var nextChange = changes[i];
// Consider the following case:
// i.e. two edits. The first represents the text change range { { 10, 50 }, 30 }. i.e. The span starting
// at 10, with length 50 is reduced to length 30. The second represents the text change range { { 30, 30 }, 40 }.
// i.e. the span starting at 30 with length 30 is increased to length 40.
//
// 0 10 20 30 40 50 60 70 80 90 100
// -------------------------------------------------------------------------------------------------------
// | /
// | /----
// T1 | /----
// | /----
// | /----
// -------------------------------------------------------------------------------------------------------
// | \
// | \
// T2 | \
// | \
// | \
// -------------------------------------------------------------------------------------------------------
//
// Merging these turns out to not be too difficult. First, determining the new start of the change is trivial
// it's just the min of the old and new starts. i.e.:
//
// 0 10 20 30 40 50 60 70 80 90 100
// ------------------------------------------------------------*------------------------------------------
// | /
// | /----
// T1 | /----
// | /----
// | /----
// ----------------------------------------$-------------------$------------------------------------------
// . | \
// . | \
// T2 . | \
// . | \
// . | \
// ----------------------------------------------------------------------*--------------------------------
//
// (Note the dots represent the newly inferrred start.
// Determining the new and old end is also pretty simple. Basically it boils down to paying attention to the
// absolute positions at the asterixes, and the relative change between the dollar signs. Basically, we see
// which if the two $'s precedes the other, and we move that one forward until they line up. in this case that
// means:
//
// 0 10 20 30 40 50 60 70 80 90 100
// --------------------------------------------------------------------------------*----------------------
// | /
// | /----
// T1 | /----
// | /----
// | /----
// ------------------------------------------------------------$------------------------------------------
// . | \
// . | \
// T2 . | \
// . | \
// . | \
// ----------------------------------------------------------------------*--------------------------------
//
// In other words (in this case), we're recognizing that the second edit happened after where the first edit
// ended with a delta of 20 characters (60 - 40). Thus, if we go back in time to where the first edit started
// that's the same as if we started at char 80 instead of 60.
//
// As it so happens, the same logic applies if the second edit precedes the first edit. In that case rahter
// than pusing the first edit forward to match the second, we'll push the second edit forward to match the
// first.
//
// In this case that means we have { oldStart: 10, oldEnd: 80, newEnd: 70 } or, in TextChangeRange
// semantics: { { start: 10, length: 70 }, newLength: 60 }
//
// The math then works out as follows.
// If we have { oldStart1, oldEnd1, newEnd1 } and { oldStart2, oldEnd2, newEnd2 } then we can compute the
// final result like so:
//
// {
// oldStart3: Min(oldStart1, oldStart2),
// oldEnd3 : Max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)),
// newEnd3 : Max(newEnd2, newEnd2 + (newEnd1 - oldEnd2))
// }
var oldStart1 = oldStartN;
var oldEnd1 = oldEndN;
var newEnd1 = newEndN;
var oldStart2 = nextChange.span().start();
var oldEnd2 = nextChange.span().end();
var newEnd2 = oldStart2 + nextChange.newLength();
oldStartN = Math.min(oldStart1, oldStart2);
oldEndN = Math.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1));
newEndN = Math.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2));
}
return new TextChangeRange(TextSpan.fromBounds(oldStartN, oldEndN), /*newLength: */newEndN - oldStartN);
}
}
}

View file

@ -1,69 +0,0 @@
///<reference path='references.ts' />
module TypeScript.SimpleText {
class SimpleStringText implements ISimpleText {
private _lineMap: LineMap = undefined;
constructor(private value: string) {
}
public length(): number {
return this.value.length;
}
public substr(start: number, length: number): string {
var val = this.value;
return start === 0 && length == val.length
? val
: val.substr(start, length);
}
public charCodeAt(index: number): number {
return this.value.charCodeAt(index);
}
public lineMap(): LineMap {
if (!this._lineMap) {
this._lineMap = LineMap1.fromString(this.value);
}
return this._lineMap;
}
}
// Class which wraps a host IScriptSnapshot and exposes an ISimpleText for newer compiler code.
class SimpleScriptSnapshotText implements ISimpleText {
private _lineMap: LineMap = undefined;
constructor(public scriptSnapshot: IScriptSnapshot) {
}
public charCodeAt(index: number): number {
return this.scriptSnapshot.getText(index, index + 1).charCodeAt(0);
}
public length(): number {
return this.scriptSnapshot.getLength();
}
public substr(start: number, length: number): string {
return this.scriptSnapshot.getText(start, start + length);
}
public lineMap(): LineMap {
if (!this._lineMap) {
this._lineMap = new LineMap(() => this.scriptSnapshot.getLineStartPositions(), this.length());
}
return this._lineMap;
}
}
export function fromString(value: string): ISimpleText {
return new SimpleStringText(value);
}
export function fromScriptSnapshot(scriptSnapshot: IScriptSnapshot): ISimpleText {
return new SimpleScriptSnapshotText(scriptSnapshot);
}
}

View file

@ -1,146 +0,0 @@
///<reference path='references.ts' />
module TypeScript {
export interface ISpan {
start(): number;
end(): number;
}
export class TextSpan implements ISpan {
private _start: number;
private _length: number;
/**
* Creates a TextSpan instance beginning with the position Start and having the Length
* specified with length.
*/
constructor(start: number, length: number) {
if (start < 0) {
Errors.argument("start");
}
if (length < 0) {
Errors.argument("length");
}
this._start = start;
this._length = length;
}
public toJSON(key: any): any {
return { start: this._start, length: this._length };
}
public start(): number {
return this._start;
}
public length(): number {
return this._length;
}
public end(): number {
return this._start + this._length;
}
public isEmpty(): boolean {
return this._length === 0;
}
/**
* Determines whether the position lies within the span. Returns true if the position is greater than or equal to Start and strictly less
* than End, otherwise false.
* @param position The position to check.
*/
public containsPosition(position: number): boolean {
return position >= this._start && position < this.end();
}
/**
* Determines whether span falls completely within this span. Returns true if the specified span falls completely within this span, otherwise false.
* @param span The span to check.
*/
public containsTextSpan(span: TextSpan): boolean {
return span._start >= this._start && span.end() <= this.end();
}
/**
* Determines whether the given span overlaps this span. Two spans are considered to overlap
* if they have positions in common and neither is empty. Empty spans do not overlap with any
* other span. Returns true if the spans overlap, false otherwise.
* @param span The span to check.
*/
public overlapsWith(span: TextSpan): boolean {
var overlapStart = Math.max(this._start, span._start);
var overlapEnd = Math.min(this.end(), span.end());
return overlapStart < overlapEnd;
}
/**
* Returns the overlap with the given span, or undefined if there is no overlap.
* @param span The span to check.
*/
public overlap(span: TextSpan): TextSpan {
var overlapStart = Math.max(this._start, span._start);
var overlapEnd = Math.min(this.end(), span.end());
if (overlapStart < overlapEnd) {
return TextSpan.fromBounds(overlapStart, overlapEnd);
}
return undefined;
}
/**
* Determines whether span intersects this span. Two spans are considered to
* intersect if they have positions in common or the end of one span
* coincides with the start of the other span. Returns true if the spans intersect, false otherwise.
* @param The span to check.
*/
public intersectsWithTextSpan(span: TextSpan): boolean {
return span._start <= this.end() && span.end() >= this._start;
}
public intersectsWith(start: number, length: number): boolean {
var end = start + length;
return start <= this.end() && end >= this._start;
}
/**
* Determines whether the given position intersects this span.
* A position is considered to intersect if it is between the start and
* end positions (inclusive) of this span. Returns true if the position intersects, false otherwise.
* @param position The position to check.
*/
public intersectsWithPosition(position: number): boolean {
return position <= this.end() && position >= this._start;
}
/**
* Returns the intersection with the given span, or undefined if there is no intersection.
* @param span The span to check.
*/
public intersection(span: TextSpan): TextSpan {
var intersectStart = Math.max(this._start, span._start);
var intersectEnd = Math.min(this.end(), span.end());
if (intersectStart <= intersectEnd) {
return TextSpan.fromBounds(intersectStart, intersectEnd);
}
return undefined;
}
/**
* Creates a new TextSpan from the given start and end positions
* as opposed to a position and length.
*/
public static fromBounds(start: number, end: number): TextSpan {
Debug.assert(start >= 0);
Debug.assert(end - start >= 0);
return new TextSpan(start, end - start);
}
}
}

View file

@ -1,94 +0,0 @@
///<reference path='references.ts' />
module TypeScript.TextUtilities {
export interface ICharacterSequence {
charCodeAt(index: number): number;
length: number;
}
export function parseLineStarts(text: ICharacterSequence): number[]{
var length = text.length;
// Corner case check
if (0 === length) {
var result = new Array<number>();
result.push(0);
return result;
}
var position = 0;
var index = 0;
var arrayBuilder = new Array<number>();
var lineNumber = 0;
// The following loop goes through every character in the text. It is highly
// performance critical, and thus inlines knowledge about common line breaks
// and non-line breaks.
while (index < length) {
var c = text.charCodeAt(index);
var lineBreakLength: number;
// common case - ASCII & not a line break
if (c > CharacterCodes.carriageReturn && c <= 127) {
index++;
continue;
}
else if (c === CharacterCodes.carriageReturn && index + 1 < length && text.charCodeAt(index + 1) === CharacterCodes.lineFeed) {
lineBreakLength = 2;
}
else if (c === CharacterCodes.lineFeed) {
lineBreakLength = 1;
}
else {
lineBreakLength = TextUtilities.getLengthOfLineBreak(text, index);
}
if (0 === lineBreakLength) {
index++;
}
else {
arrayBuilder.push(position);
index += lineBreakLength;
position = index;
lineNumber++;
}
}
// Create a start for the final line.
arrayBuilder.push(position);
return arrayBuilder;
}
export function getLengthOfLineBreakSlow(text: ICharacterSequence, index: number, c: number): number {
if (c === CharacterCodes.carriageReturn) {
var next = index + 1;
return (next < text.length) && CharacterCodes.lineFeed === text.charCodeAt(next) ? 2 : 1;
}
else if (isAnyLineBreakCharacter(c)) {
return 1;
}
else {
return 0;
}
}
export function getLengthOfLineBreak(text: ICharacterSequence, index: number): number {
var c = text.charCodeAt(index);
// common case - ASCII & not a line break
if (c > CharacterCodes.carriageReturn && c <= 127) {
return 0;
}
return getLengthOfLineBreakSlow(text, index, c);
}
export function isAnyLineBreakCharacter(c: number): boolean {
return c === CharacterCodes.lineFeed ||
c === CharacterCodes.carriageReturn ||
c === CharacterCodes.nextLine ||
c === CharacterCodes.lineSeparator ||
c === CharacterCodes.paragraphSeparator;
}
}